4 tools
Free Code Formatters
Consistent formatting makes code easier to read, review, and diff. Our code formatters run well-known open-source engines directly in your browser: Ruff for Python, and Prettier for Java and HTML, including the CSS and JavaScript inside HTML pages. Paste a snippet, choose your line length and indentation, and get the formatted result instantly, with syntax errors reported by line and column. Your code never leaves your device.
All tools
Available Code Formatters
- JSON Formatter & Validator Format, minify, validate, and sort keys in JSON strings with line and column error messages. Use Tool
- Python Formatter Format Python code with the Ruff formatter (Black-compatible), privately in your browser. Use Tool
- Java Formatter Format Java code with Prettier and prettier-plugin-java, privately in your browser. Use Tool
- HTML Formatter Beautify or minify HTML with clean indentation and error lines. Use Tool
Which one?
How to Choose the Right Tool
- To prettify, validate, or minify JSON: Use the JSON Formatter & Validator to format with custom indentation, sort object keys, minify payloads, and locate syntax errors.
- To format Python code in Black-compatible style: Use the Python Formatter, which runs the Ruff formatter with 88-column lines and double quotes by default, or 79 columns for strict PEP 8.
- To format Java classes and methods: Use the Java Formatter, which runs Prettier with prettier-plugin-java, with 4-space indentation by default and an option for Google-style 2 spaces.
- To beautify or minify HTML: Use the HTML Formatter, which runs Prettier's HTML printer with 2-space, 4-space or tab indentation, formats inline CSS and JavaScript, reports unclosed tags, and has a careful minify mode.
FAQ
Frequently Asked Questions
Is my code uploaded when I format it?
No. The formatting engines are downloaded from this site the first time you use a formatter and then run inside your browser. Your code is never sent to a server.
Which style do the formatters follow?
The Python Formatter uses the Ruff formatter, which produces Black-compatible style. The Java and HTML Formatters use Prettier, with prettier-plugin-java for Java. You can change line length and indentation on each page.
Why does the formatter report a syntax error instead of fixing my code?
A formatter only rearranges valid code. If a bracket, colon, semicolon, tag or indentation is wrong, the code cannot be parsed, so the formatter reports the line and column where parsing failed for you to fix first.