JSON formatter
Format or minify JSON and see exactly where invalid input breaks.
Output will appear here
What this JSON formatter does
JSON (JavaScript Object Notation) is the most common format for moving structured data between programs — API responses, configuration files, log lines and more. It is designed to be compact, which also makes it hard to read once objects nest a few levels deep or arrive on a single line. This tool takes any JSON you paste and rewrites it two ways: beautified, with consistent indentation so the structure is obvious at a glance, or minified, stripped of every optional space so it is as small as possible to send over the wire.
It also validates as it formats. Because it parses the text before re-serialising it, invalid JSON never produces misleading output — instead you get the exact line and column where parsing failed, so you can jump straight to the problem.
Beautify vs. minify — when to use each
The two modes serve opposite goals, and most workflows use both at different stages:
- Beautify when you are reading or debugging — inspecting an API response, comparing two payloads, or reviewing a config file in a pull request. Indentation turns a wall of text into a browsable tree.
- Minify when you are shipping — embedding JSON in HTML, storing it in a cookie or cache, or sending it in a request body where every byte counts. Minified JSON is byte-for-byte equivalent data, just without the whitespace.
The indentation selector (2 spaces, 4 spaces or a tab) only affects beautified output. Two spaces is the most common convention in JavaScript and web tooling; four spaces or tabs suit teams that prefer them. Whichever you pick, the result is still valid JSON — indentation is purely cosmetic.
Reading validation errors
When JSON is invalid, the tool reports the line and column of the first problem rather than a vague "invalid" message. Engine error messages differ across browsers and often omit a position, so the location is computed independently and points at a reasonable spot to start looking. Fix the first error and re-check — a single stray character often cascades into several apparent problems.
Common JSON mistakes
JSON is stricter than the JavaScript object literals it resembles. These are the errors that trip people up most often:
- Trailing commas: a comma after the last item in an object or array is valid in JavaScript but not in JSON.
- Single quotes: JSON strings and keys must use double quotes. 'value' is invalid; "value" is correct.
- Unquoted keys: every object key must be a quoted string, so { name: "x" } must become { "name": "x" }.
- Comments: JSON has no comment syntax. // and /* */ will cause a parse error.
- Special numbers: NaN, Infinity and -Infinity are not valid JSON numbers.
- Wrong quote characters: “smart quotes” pasted from a word processor look like quotes but are different characters and will not parse.
Frequently asked questions
- Is my JSON sent to a server?
- No. Parsing, validation and formatting all happen in your browser using JavaScript. Nothing you paste is uploaded, stored or logged, so it is safe to use with sensitive payloads.
- Does formatting change my data?
- No. Beautifying and minifying only add or remove whitespace between tokens. The keys, values, numbers and structure are identical — only the layout changes.
- Why does it reorder or reformat my numbers?
- The tool parses JSON into real values and serialises them back, so numbers are normalised to their canonical form (for example 1e3 becomes 1000). The value is unchanged; only its textual representation is standard.
- Can it handle very large JSON files?
- It can handle large payloads, but because everything runs in the browser, extremely large files (tens of megabytes) may be slow or hit memory limits depending on your device.
- Does it preserve the order of object keys?
- Yes. Key order is kept exactly as it appears in your input — the tool does not sort keys.
- What is the difference between JSON and a JavaScript object?
- JSON is a text format for data interchange; a JavaScript object is an in-memory value. JSON is stricter: it requires double-quoted keys and strings, forbids trailing commas and comments, and only allows a fixed set of value types (strings, numbers, booleans, null, arrays and objects).
- Can I format JSON5 or JSONC (JSON with comments)?
- No. This tool validates strict, standard JSON. JSON5 and JSONC add comments and other conveniences that are not part of the JSON specification, so they will be reported as errors.