About the JSON Formatter
This tool formats, minifies and validates JSON directly in your browser using the platform's own JSON.parse and JSON.stringify, so the result matches exactly what any real JSON-consuming system would accept or reject.
Paste raw or messy JSON, an API response, a log line, a config snippet, to pretty-print it with clean two-space indentation, or compact it into a single minified line to shrink a payload before it goes into an environment variable or a size-constrained field. When the input is not valid JSON, the tool surfaces the actual parse error message instead of failing silently, so you can find and fix the problem fast.
It runs entirely client-side, so you can safely paste sensitive data, tokens, connection strings, real payloads, without any of it leaving your browser. And because it is a strict validator built on the real JSON.parse, it will not silently accept near-JSON formats like JSON5 or JSONC that allow comments or trailing commas; it tells you plainly that the input is not standard JSON.
How to use it
- Paste or type your JSON into the input box.
- Click format to pretty-print it with two-space indentation.
- Click minify to compact it to a single line with no extra whitespace.
- Read the parse error message if the input is invalid JSON.
- Fix the specific issue the error names, then re-run format or minify.
- Copy the formatted or minified result with one click.
Examples
- Format {"a":1,"b":[2,3]} into an indented, multi-line block with each key and array element on its own line.
- Minify a multi-line config file down to a single line to embed in an environment variable.
- Paste JSON with a trailing comma after the last array element and get an immediate parse error naming the problem.
- Validate a webhook payload copied from a log line before wiring it into test code.
- Minify an API response to compare its exact byte size against a size budget.
- Format a deeply nested object to actually see its structure instead of one unreadable line.
Formatting vs minifying vs validating
These are three related operations behind one input. Formatting expands the JSON with two-space indentation so nested structure is easy to read. Minifying strips every character of insignificant whitespace to produce the smallest valid representation. Validation is not a separate button; both operations require the input to parse successfully first, so a failed parse produces the same error whichever button was clicked.
- Format: readable, two-space indent, larger output size, best for reviewing or debugging
- Minify: no whitespace, smallest output size, best for storing or transmitting
- Both run JSON.parse first, so an invalid input reports the same parse error either way
Why strict JSON.parse rejects things that look valid
Standard JSON is deliberately stricter than a JavaScript object literal or the more relaxed JSON5/JSONC dialects some tools accept. The rules below are the most common reasons a paste that looks fine at a glance still fails to parse.
- A trailing comma after the last array or object element
- Single-quoted strings or keys instead of double quotes
- Unquoted object keys, e.g. {name: "invoker"} instead of {"name": "invoker"}
- Comments (// or /* */), which JSON has no syntax for at all
- Values like undefined or NaN, which are valid in a JavaScript object literal but not in JSON
Large payloads and edge cases
Because everything runs client-side, there is no server-side size limit, performance is bounded only by your browser and device rather than a request timeout. Two subtler edge cases are worth knowing about regardless of size: how large integers are handled, and what happens with duplicate keys.
- Very large integers, such as 64-bit snowflake IDs, can lose precision because JavaScript numbers are IEEE-754 doubles with 53 bits of integer precision
- Duplicate object keys: only the last occurrence of a repeated key survives after parsing
- Deeply nested structures parse fine, but pretty-printed indentation can get very wide; minify first if you only need to validate, not read
Frequently asked questions
What does this JSON tool do?
It pretty-prints, minifies and validates JSON. Formatting adds readable indentation, minifying removes whitespace, and validation happens implicitly since both require the input to parse successfully.
Is my JSON sent to a server?
No. All parsing and formatting happens locally in your browser via JSON.parse and JSON.stringify, so nothing you paste is uploaded or stored anywhere.
Why does it say my JSON is invalid?
Common causes are a trailing comma, single quotes instead of double quotes, unquoted keys, or a missing bracket. The parse error message names what went wrong so you can fix it.
What is the difference between formatting and minifying JSON?
Formatting (beautifying) expands JSON with indentation for readability, while minifying strips all unnecessary whitespace to produce the smallest possible single-line output.
Does it support JSON5 or comments?
No. It validates standard JSON only, so comments, trailing commas and unquoted keys are reported as errors rather than silently accepted.
Can it handle very large numbers like 64-bit IDs?
It parses them, but JavaScript numbers are IEEE-754 doubles, so integers beyond about 2^53 can lose precision on the round trip. Keep such IDs as strings if exact precision matters.
Can I format very large JSON files?
Yes, within your browser's memory limits. Since processing is entirely client-side, performance depends on your device rather than a server, but typical API responses and config files are no problem.
What happens with duplicate keys in my JSON?
Only the last occurrence of a duplicated key survives after parsing; earlier values with the same key are silently overwritten, which matches standard JSON.parse behavior.
Does formatting change the data, or just how it looks?
Only how it looks. Formatting and minifying both re-serialize the exact same parsed data; they change whitespace and layout, not the values or key order beyond what JSON.parse already produces.
Why do single quotes cause an error?
Standard JSON requires double quotes for strings and keys. Single quotes are valid in JavaScript object literals but are not valid JSON syntax, so JSON.parse rejects them.