Java Formatter

Beautify Java code with proper indentation and brace style.

About Java Formatter

Java code formatting follows the Google Java Style Guide or Oracle Code Conventions. Standard indentation is 4 spaces. Opening braces go on the same line as the statement (K&R style), not on a new line (Allman style). Google's Java formatter, Checkstyle, and IntelliJ IDEA's built-in formatter are the standard tools. Spring Boot projects typically use Google Style with Checkstyle enforced in CI.

FAQ

Should I use Google or Oracle Java style?
Google Java Style is now dominant in modern Java projects, especially Android and Google-ecosystem projects. It uses 2-space indentation (unusual for Java), column limit of 100, and specific import ordering. Oracle/Sun style uses 4 spaces. For most new projects, Google Style with the google-java-format tool provides consistent, enforceable formatting.