How to use this developer tool
- Paste Java source.
- Choose a brace style and indentation width.
- Select cleanup options.
- Run Format Java.
- Review, copy, or download the .java output.
Format Java source by normalizing indentation, brace placement, operator spacing, blank lines, trailing whitespace, and line endings. Strings, character literals, comments, and text blocks are protected during browser-based formatting.
It applies deterministic whitespace formatting while masking literals and comments. It does not compile or alter identifiers.
This formatter is heuristic. Compile and test the output, especially when source contains unusual constructs or text blocks.
public class Test
{
public void run(){}public class Test {
public void run() {}
}Paste Java code, select a brace style and indentation width, then run the formatter.
Choose K&R or Java Standard and format the source.
Set the indent size to four; leading indentation is normalized.
Yes. Keep Remove trailing whitespace enabled.
Whitespace normally does not, but heuristic formatting should still be compiled and tested.
| Braces | Java Standard, K&R, Allman |
|---|---|
| Indentation | 2 or 4 spaces |
| Protection | Strings, comments, text blocks |
| Output | .java |