jsonecho

Java Formatter

Put Java code back into a readable layout: one statement per line, braces indented.

Loading the tool...

How to use Java Formatter

  1. Paste the Java code.
  2. Select the indent.
  3. Copy the result.

About Java Formatter

Snippets copied from a forum, a PDF or a chat lose their indentation sooner or later. This tool re-indents Java by its braces, starts a new line after every statement and leaves string literals and comments alone.

It is a layout fixer for snippets, not a replacement for google-java-format or your IDE, which also reorder imports and wrap long lines.

Frequently asked questions

Which style does it use?

Braces on the same line and a four-space indent, similar to the Oracle and Google conventions.

Does it handle annotations and generics?

Yes. They are treated as part of the statement they belong to, and stay on its line.

Does it sort the imports?

No, use your IDE or google-java-format.

More in Code Formatters

All tools →