Java Formatter
Give messy Java source clean, consistent brace indentation — generics and literals untouched.
About this tool
Code from slides, logs or old forums loses its indentation fast. This formatter re-indents Java
source: every brace opens a new indent level, statements end cleanly at semicolons, and generic
type arguments such as List<Map<String, Integer>> stay glued together
instead of being spaced apart.
How to use it
- Paste your Java code, or click Sample.
- Pick an indentation (4 spaces is the Java convention) and click Format Java.
- Copy the result back into your IDE.
Good to know
- String literals, char literals and both comment styles are preserved exactly.
- Annotations such as
@Overridestay attached to what follows them. - It is a basic formatter: exotic layouts (long parameter lists wrapped by hand, aligned assignment blocks) are normalised rather than preserved.