Developer Tools calculator

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.

InputsLive
Tool
Input
Result
JSON
Enter input above to get started.

Output is generated client-side in your browser. No data is transmitted to any server.

Results are estimates. Consult a professional.

What it does

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.

Formatting is not changing the data
Beautifying and minifying only change whitespace. The keys, values, and structure stay identical — a formatted document and its minified twin parse to exactly the same object. Formatting never edits your data; it only changes how the text is laid out.
How it works

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: parse(text) → serialize with indent (2 / 4 spaces)
minify: parse(text) → serialize with no whitespace
validate: parse(text) → error if the grammar is broken
JSON's data model and grammar — objects, arrays, the six value types, and the rule that strings use double quotes — are defined in RFC 8259 (IETF, the JSON Data Interchange Format) and the byte-for-byte compatible ECMA-404 standard.
Beautify vs minify

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.

Example

A worked example: compact JSON to indented

Example: beautifying a one-line API response

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:

{"name":"Ada","langs":["JS","Py"],"active":true}

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:

{
"name": "Ada",
"langs": [
"JS",
"Py"
],
"active": true
}
Same data, readable shape
Switch the mode back to minify and you get the original one-line {"name":"Ada","langs":["JS","Py"],"active":true} again. Both forms hold identical data — only the whitespace differs.
Where it helps

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 filespackage.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.
Validation

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:

MistakeAllowed?Why
Trailing comma — {"a":1,}NoJSON forbids a comma after the last element of an object or array
Single quotes — {'a':1}NoAll strings and keys must use double quotes
Unquoted keys — {a:1}NoEvery key is a double-quoted string; bare identifiers are not JSON
Comments — // or /* */NoJSON has no comment syntax; remove them before parsing
undefined, NaN, InfinityNoNot JSON values — only string, number, boolean, null, object, array exist
Leading zero or +sign — 01, +5NoNumbers 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.

Comments are the classic trap
People add // notes to a config file, then a strict parser rejects it. Formats like JSON5 or JSONC allow comments and trailing commas, but they are extensions — strict JSON, the kind APIs speak, allows neither.
Production

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.

Privacy

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.

Definitions

JSON formatter definitions

JavaScript Object Notation — a lightweight, text-based format for structured data built from objects, arrays, strings, numbers, booleans, and null. It is language-independent despite the name and is the default format for web APIs and config files.
Re-printing JSON with line breaks and indentation so the nesting is visible. Adds whitespace for readability without changing any data.
Re-printing JSON with all optional whitespace removed, producing the smallest single-line form. Used for production payloads where size matters.
Reading JSON text and turning it into an in-memory data structure. Parsing also validates: text that breaks the JSON grammar fails to parse.
The reverse of parsing — turning an in-memory value back into JSON text. Formatting is a parse followed by a serialize with the whitespace you choose.
The two normative specifications that define JSON. RFC 8259 is the IETF standard; ECMA-404 is the byte-for-byte compatible ECMA standard. Both fix the same strict grammar.
Accuracy

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).
Questions

Frequently asked questions about the free JSON formatter (pretty / minify)

A JSON formatter calculator is a free online tool that helps you pretty-print or minify JSON with automatic syntax validation. JSON.stringify with a custom indent emits formatted JSON; without an indent, single-line minified output. It runs entirely in your browser with instant results and no sign-up.
Common issues: trailing commas (not allowed), single quotes (use double), comments (not allowed), unescaped backslash / newline in strings.
2 spaces is the JavaScript convention. 4 is common in Python. For deeply nested data, 2 is more readable per line; 4 makes nesting clearer.
No — only checks syntax (is it valid JSON?). For schema validation (does it match expected structure?), use Ajv or similar.
About

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.

Want a calculator built for your business?

Customize any of our 400+ tools to match your brand, or commission a new one tailored to how your business actually calculates — pricing, payroll, quotes, anything. Deployed on your domain, math runs in your visitors' browsers.