Java beautifier - format Java in your browser with the real clang-format
Java gets a full reformat in the browser, not just an indent fix. Under the hood it runs **clang-format** (first-class Java support, Google style) - the original compiler-grade formatter compiled to WebAssembly. The same one you use in the terminal or in CI.
What this means in practice: it wraps long lines (100 chars by default), normalises indentation (tab / 2 / 4 spaces - your pick), normalises spacing around operators, aligns function arguments, respects the language's idiomatic conventions (`if (x)` vs `if(x)`, etc.). Exactly what `Format Document` does for Java in VS Code with the official extension.
Accepts .java files. Everything runs in your browser - the code never leaves your machine, no upload, no server-side logs. The WASM blob lazy-loads on the first click (60-300 kB), subsequent formats are instant.
clang-format treats Java as a first-class target - alongside C/C++/C#. Default style Google Java Style (4 spaces, 100-column, K&R braces). It handles annotations (`@Override`, `@Nullable`), generics (`List<Map<K,V>>`), lambdas (`stream.map(x -> x.foo())`), switch expressions (Java 14+). Full reformat, not just indentation.
How to use it
- Pick a mode (Gentle / Aggressive / Cosmetic-only) or keep the default.
- Paste your code into the left panel, or use "Upload file".
- Tune settings (gear icon): indent, width, quotes, semicolons.
- Click Format - first click takes a moment (libraries lazy-load).
- On the right you get the output with syntax highlighting - copy, download, or open in new tab.
When this is useful
Five typical Java situations:
- Pretty-print a messy source. Code you pasted from a colleague / a PDF / a blog post has broken indentation. clang-format does a full reformat in a second.
- PR review. The team uses a consistent style - clang-format enforces the official style of the language, so code review stops shouting about whitespace.
- Convert tabs to spaces (or back). One project's `.editorconfig` says 4 spaces, another says 2 - switch in the settings popover.
- Sanity-check syntax. If clang-format rejects the code with a parse error you have a syntax typo - a quick sanity check before kicking off a build.
- Syntax-highlighted preview. After formatting you get a coloured preview (powered by Shiki, the same TextMate grammars VS Code uses).