Code Formatter
Format and beautify JSON, YAML, TOML, XML, HTML, and CSS — with JSON/CSS minify and JSON schema validation.
Prefer the terminal? See the CLI equivalent →About the Code Formatter
- Format & validate
- Syntax highlighting
- Send output to other tools
- Instant results
- 100% private — runs in your browser
- Free, no sign-up
A formatter (or beautifier) rewrites code and data with consistent indentation, spacing, and line breaks so it is easy to read, review, and diff — without changing what it means. This tool formats the structured languages developers deal with every day: JSON, YAML, TOML, XML, HTML, and CSS. It runs entirely in your browser, so even large or sensitive files never leave your machine.
Beyond pretty-printing, it can minify JSON and CSS — stripping whitespace to produce the smallest equivalent output for production — and validate JSON against a JSON Schema, highlighting the exact location of any error inline in the editor. That makes it useful both for tidying up an API response you are debugging and for catching structural mistakes before they reach a build.
Formatting only reflows the text; it never alters values, key order (unless the format requires it), or semantics. If the input is invalid — a missing brace, a bad indent — you get a clear error pointing at the problem rather than silently mangled output.
How to use it
- Select the language, then paste your code — or load a file with the ⬆ upload button in the editor toolbar.
- Click Format to pretty-print with consistent indentation, or Minify (JSON and CSS) to compress it.
- For JSON, optionally add a JSON Schema (a second editor) to validate the document; any violations are marked inline with a message.
- Copy or download the result from the editor toolbar; use ⛶ to expand the editor, or both editors when the schema is shown.
- For JSON, use the “Send to…” buttons to open the document in the Types generator or JSONPath Tester.
Supported languages
- JSON
- Format, minify, and validate against a JSON Schema. The most common config and API-response format.
- YAML
- Human-friendly config format; formatting normalises indentation and spacing.
- TOML
- Config format used by many modern toolchains; tidied into a canonical layout.
- XML
- Reindented with proper nesting for documents, feeds, and SOAP payloads.
- HTML
- Beautified markup with readable indentation for templates and fragments.
- CSS
- Format for readability or minify to reduce stylesheet size.
Frequently asked questions
Does formatting change my data?+
No. Formatting only changes whitespace and layout, never the values or structure. A formatted document is semantically identical to the original — it just reads better and diffs more cleanly.
What is the difference between formatting and minifying?+
Formatting adds indentation and line breaks to make code readable for humans. Minifying does the opposite — it removes all unnecessary whitespace to produce the smallest possible output for delivery to a browser or API. Both preserve meaning; they optimise for different audiences.
How does JSON Schema validation work?+
Paste a JSON Schema alongside your JSON and the tool checks the document against it — required properties, types, formats, and constraints. Any violation is reported with the path to the offending value, so you can fix structural errors before they reach your application.
Why does it report an error instead of formatting?+
The input must be syntactically valid to be formatted. A missing comma, unbalanced bracket, or bad indentation will produce a parse error with the location of the problem. Fix the highlighted issue and the document will format.
Is there a size limit?+
There is no fixed limit, but very large documents (tens of megabytes) may format slowly because everything runs in your browser. For typical config files and API responses it is effectively instant.
Works well with
Code Formatter chains with these tools — send your result straight on:
Related tools
Data Diff
Compare two JSON, YAML, or TOML documents by structure, not text: added, removed, and changed values with their paths. Key order and formatting are ignored. Runs in your browser.
HAR Viewer
Open a .har network export and explore its requests, sizes, status codes, and a timing waterfall — entirely in your browser. Nothing is uploaded.
JSON ↔ YAML ↔ TOML
Convert structured data between JSON, YAML, and TOML, live in your browser.
JSON to SQL
Infer a SQL CREATE TABLE from a JSON sample or a JSON Schema — column types, nullability, and a primary-key guess — for PostgreSQL, MySQL, or SQLite. Runs in your browser.
JSON to Types
Turn a JSON sample or a JSON Schema into TypeScript, Zod, Go structs, Python dataclasses, Kotlin data classes, or Java records/Lombok. Infers optional and nullable fields. Runs in your browser.
JSONPath Tester
Query JSON live with JSONPath — filter, slice, and recurse, and see each matched value with its path, all in your browser.