About JSON Formatter

Format, minify, and validate JSON with syntax highlighting. Free, no sign-up required.

How to use

  1. Paste your raw or messy JSON into the left textarea. The tool also auto-formats on paste — drop in a single-line minified payload and the right pane immediately shows it indented two spaces deep.
  2. Click Format / Beautify (the default mode) to pretty-print: parses the input, then JSON.stringify(parsed, null, 2) to emit canonically-formatted output with consistent quoting, spacing, and key order preservation.
  3. Click Minify to collapse to a single line with no whitespace — useful for shipping a payload over a tight wire, embedding into an environment variable, or copying into a single-line API call. Output is byte-for-byte equivalent in semantics, just without indentation.
  4. Click Validate Only to run the parse step without re-stringifying. The status bar reports either valid (with size and node count in the insights box) or the precise error and offset, e.g. 'Unexpected token } at position 87' — the most efficient way to find a stray comma in a large file.
  5. Use the Sample button to load a representative JSON document if you just want to see the formatter in action, or to share a starting point with a collaborator. Clear wipes both panes.
  6. Once formatted, hit Copy to push the result to clipboard or Download to save as formatted.json. The download is a real file — drag into VS Code, your text editor, or attach it to an email.

Examples

Beautify a minified API response
Input: {"name":"Alice","age":30,"tags":["admin","editor"]}. Output (formatted): proper indentation with each tag on its own line. Browsers and most APIs minify by default to save bandwidth — beautifying makes them legible during debugging.
Catch a trailing comma
Input: {"a": 1, "b": 2,}. Validate reports: 'Unexpected token } in JSON at position 14'. Strict JSON forbids trailing commas (unlike JavaScript objects). The fix is to remove the comma after 2 — JSON5 and JSONC permit them, but standard JSON parsers reject.
Spot a numeric type leak
Input: {"id":12345678901234567890}. JSON parses this as a Number, but JavaScript Numbers lose precision past 2^53 - 1, so the result becomes 12345678901234567000. The formatter shows the truncated value — safer to send large IDs as strings: {"id":"12345678901234567890"}.

Frequently asked questions

What are the most common JSON syntax errors?
(1) Trailing commas — {"a":1,} is invalid even though JS allows it. (2) Unquoted keys — {a:1} is JS object literal syntax, not JSON; keys must be double-quoted strings. (3) Single quotes — JSON requires double quotes everywhere. (4) NaN, Infinity, undefined — JSON has no representation for these; Number values must be finite. (5) Comments — strict JSON forbids // and /* */; use JSONC if you need them. (6) Unescaped control characters in strings — newlines, tabs must be escaped (\n, \t).
When should I use JSON5 instead of strict JSON?
JSON5 is a superset that allows comments, trailing commas, single-quoted strings, unquoted keys, hex numbers, and explicit NaN/Infinity. Use it for human-edited config files (TypeScript's tsconfig.json is actually JSONC, a similar superset). Never use JSON5 for API payloads, inter-service communication, or anywhere a stock JSON.parse() will read the data — those tools all reject the extensions. The browser fetch().json() expects strict JSON.
How is NDJSON / JSONL different from regular JSON?
NDJSON (Newline Delimited JSON) and JSONL (JSON Lines) are the same format: one valid JSON value per line, no enclosing array. {"a":1}\n{"a":2}\n{"a":3} is three records. This is friendlier for streaming — you can parse one line at a time without loading the whole file. Most log pipelines (Loki, Splunk, Datadog) prefer it. The formatter currently expects a single JSON document; for NDJSON, split on newlines and format each line individually.
Why does JSON.stringify drop my function or undefined values?
JSON has no representation for functions, Symbols, or undefined. JSON.stringify silently omits keys whose values are any of those, and converts undefined array elements to null. Date objects become ISO strings. Map and Set become {} (empty object) unless you provide a replacer. To round-trip complex structures, either flatten to JSON-safe types before stringifying, or use a tagged-format library like superjson.
What is JSON Pointer and when is it useful?
RFC 6901. JSON Pointer (e.g., /users/0/email) is a string syntax that addresses a specific value inside a JSON document by walking object keys and array indices. It is used in JSON Patch (RFC 6902) for describing partial updates: [{op:'replace', path:'/users/0/email', value:'new@x.com'}]. Useful for collaborative editors, configuration deltas, and any scenario where you need to describe a JSON change without sending the whole document.
How big a JSON file can JSON.parse handle?
Browser-side, JSON.parse holds the entire parsed object in memory, so practical limit is RAM-bound — roughly 100-500 MB before you hit single-tab heap caps and parsing latency exceeds the user's patience. For larger payloads use a streaming parser like clarinet, oboe.js, or Node's stream-json. The formatter is in-memory; pasting a 200 MB JSON will likely freeze the tab. For multi-GB scientific datasets, use NDJSON or a binary format like Parquet/Arrow instead.
What is JSONP and is it still relevant?
JSONP (JSON with Padding) wraps JSON in a function call: callback({"a":1}). It was a 2000s hack to bypass same-origin policy by loading the response via a