Free JSON formatter (pretty / minify)
Paste raw or minified JSON and this JSON formatter beautifies it with 2- or 4-space indentation, minifies it back to one line, and validates the syntax — catching trailing commas, single quotes, and other errors — updated live, as you type.
On this page14 sections
Output is generated client-side in your browser. No data is transmitted to any server.
Results are estimates. Consult a professional.
What the JSON formatter does
A JSON formatter takes raw JSON text and re-prints it cleanly — either beautified with line breaks and indentation so a human can read it, or minified down to a single line so a machine can ship it. JSON (JavaScript Object Notation) is the format almost every web API, config file, and log line uses to exchange structured data, and it is defined by two matching standards: RFC 8259 and ECMA-404. This tool reads that text, checks that it is valid JSON, and rewrites it in the shape you choose.
The formatter above does three jobs at once. It beautifies compact JSON into an indented, readable tree; it minifies indented JSON back to one line for production; and it validates as it goes — if the input is not legal JSON, it stops and tells you, instead of silently producing garbage. The output updates the moment you paste or type, with no button to press.
How JSON formatting works: parse, then re-serialize
Formatting JSON is two steps under the hood: parse, then serialize. First the tool parses your text — it reads the characters and builds an in-memory tree of objects, arrays, strings, numbers, booleans, and nulls, following the grammar in the JSON specification. If any character breaks that grammar, parsing fails and you get a syntax error. If it succeeds, the tool then serializes that tree back to text, this time inserting (or removing) whitespace to match the style you asked for.
Beautify vs minify: when to use each
Beautify and minify are opposites, and you want different ones at different times. Beautifying adds indentation and newlines so the nesting is visible — this is what you want while reading, debugging, or editing JSON by hand. Minifying strips every optional space and newline so the document is as small as possible — this is what you want when JSON travels over a network or sits in a production bundle, where every byte counts.
- Beautify (pretty-print) — for humans. Indented two or four spaces, one key per line, easy to scan and diff. Use it to read an API response or audit a config file.
- Minify (compact) — for machines. No spaces, no newlines, smallest possible size. Use it for request bodies, API payloads, and anything you send across the wire.
On indent depth: 2 spaces is the JavaScript and web convention and keeps each line short; 4 spaces is common in Python and makes deep nesting easier to follow. Both are equally valid — JSON itself does not care how much whitespace you use, because all of it is optional between tokens.
A worked example: compact JSON to indented
You copy this object out of a network response, all on one line, and you cannot tell where one field ends and the next begins:
Step 1 — Parse and validate
The formatter parses the text into a tree: an object with a string name, an array langs of two strings, and a boolean active. It is valid JSON, so formatting proceeds.
Step 2 — Serialize with 2-space indentation
Choosing beautify, 2 spaces, the tool re-prints the same tree with one key per line and the array expanded:
What developers use a JSON formatter for
JSON is everywhere data moves between programs, so a formatter earns its keep in everyday work. The common thread is the same: you have JSON that a machine produced, and you need to read, check, or reshape it.
- Debugging API responses — REST and GraphQL endpoints usually return minified JSON. Beautifying it makes the structure visible so you can find the field you need.
- Editing config files —
package.json,tsconfig.json, and countless tool configs are JSON. Pretty-printing keeps them readable and reveals a misplaced bracket fast. - Reading logs — structured logs emit one JSON object per line. Formatting a single line unpacks it into something a human can scan.
- Shrinking payloads — minifying before you send a request body or embed JSON in a page trims bytes off every transfer.
- Catching mistakes — the validation step flags a broken document before you paste it into code and chase a runtime error later.
Common JSON syntax errors the validator catches
Strict JSON is deliberately narrow — much narrower than JavaScript object literals, which is what trips most people up. The validator parses against the RFC 8259 grammar, so anything outside it is rejected. These are the mistakes it catches most often:
| Mistake | Allowed? | Why |
|---|---|---|
| Trailing comma — {"a":1,} | No | JSON forbids a comma after the last element of an object or array |
| Single quotes — {'a':1} | No | All strings and keys must use double quotes |
| Unquoted keys — {a:1} | No | Every key is a double-quoted string; bare identifiers are not JSON |
| Comments — // or /* */ | No | JSON has no comment syntax; remove them before parsing |
| undefined, NaN, Infinity | No | Not JSON values — only string, number, boolean, null, object, array exist |
| Leading zero or +sign — 01, +5 | No | Numbers cannot have a leading zero or a leading plus |
Rejection rules follow the JSON grammar in RFC 8259 §2–§6. JavaScript accepts several of these in source code, but they are not valid JSON.
Minifying JSON for smaller payloads
Whitespace in JSON exists only for human eyes — a parser ignores it entirely. That makes minifying a free win in production: stripping the indentation and newlines shrinks the document with zero effect on the data. On large, deeply nested objects, the indentation alone can be a meaningful share of the bytes, so a request body or an embedded config gets smaller and faster to transfer.
The rule of thumb: beautify while you work, minify before you ship. Keep a readable version for editing and review, then run it through minify for the payload that actually crosses the network. Because both forms parse to the same object, you never lose anything by switching between them. For even smaller transfers, servers usually layer gzip or brotli compression on top of minified JSON.
Does this JSON formatter send my data anywhere?
No. The formatting runs entirely in your browser. The JSON you paste is parsed and re-serialized locally with the browser's own JSON engine — it is never stored, logged, or sent to any server, because no network request is made. The tool works the same offline.
That matters because JSON payloads often carry sensitive data — auth tokens, API keys, customer records, internal IDs. Many online JSON tools POST your input to a backend to format it, which means your data leaves your machine. This one does not: a payload you paste here stays on your device. Even so, it is good practice to redact real secrets before pasting JSON into any tool.
JSON formatter definitions
How reliable is this JSON formatter?
The formatting is exact. Output is produced by the browser's native JSON parser and serializer, which implement the RFC 8259 grammar, so a valid document round-trips faithfully and an invalid one is reported rather than silently mangled. The beautified output matches JSON.stringify(value, null, indent) and the minified output matches JSON.stringify(value) exactly.
One thing to know: a JSON formatter checks syntax, not schema. It confirms the text is valid JSON; it does not confirm the document has the fields or types your application expects — that is schema validation, a separate job handled by tools like JSON Schema. For related encoding and pattern work, see our Base64 encoder and regex tester.
JSON's grammar, value types, and the requirement for double-quoted strings are defined in RFC 8259, "The JavaScript Object Notation (JSON) Data Interchange Format" (IETF, December 2017).Frequently asked questions about the free JSON formatter (pretty / minify)
About this JSON formatter
This JSON formatter runs entirely in your browser. The JSON you paste is parsed and re-serialized locally with the browser's own JSON engine — nothing is stored, logged, or sent to any server, so it works the same offline and keeps sensitive payloads on your device. Beautify to read it, minify to ship it, and the validator flags broken syntax as you type.
It is one of our free developer tools; browse the full set on the calculators index.