Skip to content

Java Formatter

Format Java source code with Prettier and prettier-plugin-java: classes, records, lambdas, generics and long call chains.

Runs in your browserJava → Java
Loading tool…

Example

Input
public class Hello{public static void main(String[] args){System.out.println("Hi");}}
Output
public class Hello {

    public static void main(String[] args) {
        System.out.println("Hi");
    }
}

How to use the Java Formatter

  1. Paste a complete compilation unit (a class, interface, enum or record), or load a .java file.
  2. The output follows the prettier-java style, which adds a blank line before the first class member.

Privacy and limitations

  • Your data is processed on your device and is not uploaded to any server.
  • The input must be syntactically valid Java; code fragments such as a lone statement or method cannot be formatted.
  • Syntax errors are reported without a line number because the parser does not expose one.
  • The style is fixed to prettier-java conventions; only indentation and print width are configurable.

Frequently asked questions

Is my code uploaded?

No. The parser is a WebAssembly module that runs in your browser; it is downloaded the first time you format.

Browse all beautifiers & formatters →