Online JSON Formatter — Free, Instant, and Private
This online JSON formatter turns unreadable JSON into clean, indented, human-readable structure in a single click — and tells you exactly what is wrong when the JSON will not parse. Paste a minified API response, a log line, or a configuration file into the panel above, choose an indentation width, and read the result.
Everything runs inside your browser. There is no upload step, no server round-trip, no account, and no size limit beyond your own machine's memory. If you are debugging a response that contains an auth token or customer data, that distinction matters: the JSON never leaves your device.
What a JSON Formatter Actually Does
JSON — JavaScript Object Notation — is the dominant data-interchange format on the web, standardised as RFC 8259 by the IETF and, in parallel, as ECMA-404. It was specified by Douglas Crockford in the early 2000s and documented at json.org, which remains the canonical one-page grammar reference.
Under that grammar, whitespace between tokens is insignificant. These two documents are the same data:
{"id":42,"name":"Ada Lovelace","roles":["admin","engineer"],"active":true}
{
"id": 42,
"name": "Ada Lovelace",
"roles": [
"admin",
"engineer"
],
"active": true
}
A formatter re-serialises the parsed value with newlines and indentation so the nesting becomes visible. Because it parses first and prints second, formatting is also validation — if the document is malformed, there is nothing to re-print, and you get an error instead.
That is the mechanism behind every "pretty print" button, including this one. Internally it is the same operation as JSON.stringify(value, null, 2) in JavaScript, json.dumps(obj, indent=2) in Python, or jq . on the command line.
Format, beautify, pretty-print, prettify
These are four words for one operation. The ECMAScript specification for JSON.stringify calls the third argument the space parameter and the result "pretty-printed." Editor tooling tends to say "beautify." Developers mostly say "format." Search engines treat them as distinct queries; the underlying transformation is identical.
Minifying is the inverse: strip every optional character to produce the smallest byte-equivalent document.
How to Format JSON Online
- Paste your JSON into the input panel. Minified one-liners, already-indented documents, and broken JSON you are trying to debug are all accepted.
- Choose your output. Format (2 spaces) is the convention in the JavaScript and TypeScript ecosystem and what
npmwrites intopackage.json. Format (4 spaces) matches Python and .NET house style and is easier to scan on wide screens. Minify strips all insignificant whitespace. - Copy the result with the copy button, or read the error message if the document did not parse.
There is no third step for validation — it happens automatically, because a document that cannot be parsed cannot be formatted.
Reading JSON Error Messages
Most time lost to JSON is not spent formatting it. It is spent working out why a document that looks fine refuses to parse. JSON is considerably stricter than JavaScript object syntax, and nearly every error traces back to that gap.
| Error you see | What actually caused it | Fix |
|---|---|---|
Unexpected token } in JSON | Trailing comma after the final property or element | Delete the comma before } or ] |
Unexpected token ' in JSON | Single-quoted string or key | JSON permits double quotes only |
Unexpected token n in JSON | Unquoted key copied from a JS object literal | Quote every key: {"name": …} |
Unexpected end of JSON input | Truncated document — unclosed brace, bracket, or quote | Check the document is complete |
Unexpected token < in JSON | The response was HTML, not JSON — usually an error page | Inspect the actual HTTP response and status code |
Bad control character in string | A literal newline or tab inside a string | Escape as \\n or \\t |
Unexpected token in JSON at position 0 | Byte order mark (BOM) before the first character | Re-save the file as UTF-8 without BOM |
The five rules that cause almost every failure
- Double quotes only. Both keys and string values.
'single'is invalid; so is an unquoted key. - No trailing commas. Valid in modern JavaScript, invalid in JSON. This is the single most common error.
- No comments. Neither
//nor/* */. See the FAQ below for why, and what to do instead. - Numbers are plain decimals. No leading
+, no leading zeros, no hex, noNaN, noInfinity..5is invalid — write0.5. - Only three literals, all lowercase:
true,false,null.TrueandNULLare not JSON.
The reason {name: 'Ada'} fails is that it is a JavaScript object literal, not JSON. The two look similar and are not the same language. Anything you copy out of a .js file needs checking against the five rules above.
Formatting vs Minifying: Which Do You Need?
| Format (pretty-print) | Minify | |
|---|---|---|
| Output | Indented, one token group per line | Single line, no optional whitespace |
| Size | Larger — often 30–50% more bytes | Smallest possible |
| Use for | Reading, debugging, diffing, code review, committed config files | URL parameters, data attributes, size-limited fields, embedded payloads |
| Git diffs | Clean line-by-line changes | One enormous unreadable line |
A point worth making, because a lot of advice online gets it wrong: minifying JSON for API responses is usually not worth doing. Production HTTP traffic is gzip- or Brotli-compressed, and compression algorithms handle repeated indentation almost for free. The bandwidth saving is typically negligible.
Minify when the JSON has to fit somewhere constrained — a query string, an HTML data- attribute, a message queue with a payload cap. Keep files that humans read and diff — package.json, tsconfig.json, composer.json, fixture files — formatted and committed that way. A minified file in version control makes every future diff unreadable, in exchange for bytes your transport layer would have compressed anyway.
Indentation: 2 Spaces or 4?
Neither is more correct; JSON has no opinion. Convention differs by ecosystem:
- 2 spaces — JavaScript, TypeScript, and Node. This is what
npmwrites intopackage.json, and what Prettier produces by default. Choose it if your JSON lives beside JS/TS code. - 4 spaces — Python (
json.dumps(obj, indent=4)), .NET, and Java tooling. Easier to scan for deeply nested documents on a wide screen. - Tabs — rare in JSON, though permitted. Avoid unless a house style requires it; tab width varies between viewers, so shared files render inconsistently.
The rule that actually matters is consistency within a repository. Mixed indentation produces spurious diffs where nothing meaningful changed. If your project runs Prettier or EditorConfig, let it own the decision.
Common Use Cases
Debugging API responses. A REST or GraphQL endpoint returns a single minified line. Paste it here to see the structure, confirm which fields are present, and check whether a value is null, "", or absent — three different states that minified JSON makes nearly impossible to distinguish by eye.
Reading log output. Structured loggers such as Pino, Winston, Bunyan, and structlog emit one JSON object per line. Formatting a single line turns an unreadable wall of text into a readable event.
Fixing configuration files. package.json, tsconfig.json, composer.json, .eslintrc.json, and CI manifests are all JSON, and a stray comma in any of them breaks the build with a message that rarely points at the real line.
Validating before deployment. Infrastructure definitions, feature-flag payloads, and seed data are worth validating before they reach an environment where a parse error becomes an outage.
Preparing data for review. Formatted JSON in a pull request or a piece of documentation is reviewable. Minified JSON is not.
Inspecting JWT payloads. The decoded body of a JSON Web Token is JSON. Paste it here to read the claims — or use the JWT Decoder, which handles the Base64URL step for you.
Working With JSON in Your Own Code
The same operation this page performs is available in every major language:
// JavaScript / Node.js
const formatted = JSON.stringify(JSON.parse(raw), null, 2);
const minified = JSON.stringify(JSON.parse(raw));
# Python
import json
formatted = json.dumps(json.loads(raw), indent=2)
minified = json.dumps(json.loads(raw), separators=(",", ":"))
# Command line — jq
jq . response.json # format
jq -c . response.json # minify
Two details that catch people out. In JavaScript, JSON.stringify silently drops undefined values, functions, and symbols from objects, and converts them to null inside arrays — so a round-trip is not always lossless. In Python, json.dumps defaults to sort_keys=False but adds a space after separators; pass separators=(",", ":") for a genuinely minimal document.
For editor-based formatting, VS Code formats JSON natively with Shift+Alt+F (Windows/Linux) or Shift+Option+F (macOS) — no extension needed.
Privacy and Security
This tool performs all parsing and serialisation locally using your browser's built-in JSON implementation. Concretely:
- No upload. The JSON is never transmitted anywhere.
- No storage. Nothing is written to a database, a log, or local storage.
- No account. There is nothing to sign up for and no identity attached to your usage.
- Works offline. Once loaded, the page needs no network connection.
That makes it a reasonable choice for API responses containing tokens or personal data. Standard caution still applies: treat any browser tool as untrusted for live production credentials, and rotate anything you would not want in your clipboard history.
Frequently Asked Questions
Is this JSON formatter free?
Yes — no signup, no usage cap, no paid tier. There is no document size limit beyond your browser's memory, because processing happens on your device rather than on a server we would have to pay for.
Is my JSON data uploaded to a server?
No. Formatting, minifying, and validation run in JavaScript in your browser via the native JSON.parse and JSON.stringify methods. Your data never leaves your device and is never logged or stored.
What is the difference between formatting, beautifying, and pretty-printing JSON?
They are three names for the same operation: adding newlines and indentation so the nesting is visible. "Pretty-print" comes from the JavaScript specification, "beautify" from editor tooling, "format" from everyday usage. None of them alter the data.
Does formatting JSON change my data?
No. Whitespace between tokens is insignificant under RFC 8259, so re-indenting produces a document that parses to an identical value. Two caveats: key order is preserved as written but is not meaningful in the JSON object model, and numbers are normalised — 1.50 becomes 1.5, 1e3 becomes 1000 — because both round-trip through a double-precision float.
Why does my JSON say "Unexpected token" when it looks correct?
Almost always a trailing comma, single quotes instead of double, an unquoted key copied from a JavaScript object, an unescaped newline inside a string, or an invisible BOM at the start of the file. See the error table above for the specific fix.
Can I use this JSON formatter offline?
Yes. After the page loads, no network connection is required — every operation runs locally.
Which JSON specification does this validator use?
RFC 8259, the current IETF Internet Standard, semantically aligned with ECMA-404. It supersedes RFC 4627 and RFC 7159. Any well-formed JSON value is accepted at the top level — not only objects and arrays.
What is the maximum JSON file size I can format?
No artificial limit. The practical ceiling is browser memory and single-threaded JavaScript. A few megabytes format instantly; tens of megabytes may briefly freeze the tab. For very large datasets, use a streaming parser locally.
Should I minify JSON before sending it over an API?
Usually not worth it — production traffic is already gzip- or Brotli-compressed, and compression handles whitespace efficiently. Minify for URLs, data attributes, and size-capped fields. Never minify config files that humans read and diff.
Can JSON contain comments?
Not under the specification — Crockford removed them deliberately to prevent their use as parsing directives. Some tools accept a relaxed superset (VS Code calls it JSONC, used for settings.json and tsconfig.json), but a compliant parser rejects them. Strip comments before validating, or store the note in a normal key such as "_comment".
Learn More About JSON
These guides go deeper than a tool page can. Each one is written to be read once and returned to when something breaks.
- JSON Guide — the complete reference: types, grammar, and everything below in one place.
- JSON Syntax Rules — the full grammar, and the exact ways JSON is stricter than JavaScript.
- Common JSON Errors — every parse error, its real cause, and the fix.
- How to Format JSON — pretty-printing, 2 vs 4 spaces, and formatting in every major language.
- JSON Validation — syntax checking versus JSON Schema, and when you need each.
- Minifying JSON — what it saves, and why it is usually pointless on API responses.
- JSON vs XML vs YAML — an honest comparison, including where JSON is the wrong choice.
- JSON Best Practices — naming, dates, money, nulls, and API response structure.
How This Formatter Compares
Wondering whether this is the best JSON formatter for your workflow? We wrote honest, sourced comparisons with the tools you are probably considering — including what each one does better than us:
- vs JSONLint — the best-known validator, with repair and JSONPath tools.
- vs JSONFormatter.org — broad conversion features; read its save-data policy first.
- vs CodeBeautify — a huge toolbox, with a caveat about saved documents.
- vs JSON Editor Online — a full editor for large documents; different job.
- vs Chrome extensions — when an extension helps, and what permissions it costs.
Related JSON and Data Tools
- JSON to CSV — flatten a JSON array into a spreadsheet.
- CSV to JSON — convert spreadsheet rows into a JSON array.
- JSON to PDF — produce a formatted PDF report from JSON.
- JWT Decoder — decode a JSON Web Token and inspect its claims.
- Base64 Encoder & Decoder — for JSON embedded in Base64 payloads.
- Regex Tester — build and test patterns against extracted JSON strings.
Reference and Further Reading
- json.org — Douglas Crockford's canonical grammar reference.
- RFC 8259 — the current IETF Internet Standard for JSON.
- ECMA-404 — the parallel ECMA syntax standard.
- MDN: JSON.stringify() — pretty-printing and the replacer/space parameters.
- MDN: JSON.parse() — parsing behaviour and the reviver function.
- JSON Schema — for validating structure and types, not just syntax.