JSON Formatter & Validator
Beautify, minify, and validate JSON — with clear error messages when something's wrong.
How to use the JSON Formatter
- Paste your JSON into the Your JSON box.
- Press Format / Beautify for an indented, readable version, or Minify to strip all whitespace for the smallest payload.
- If the JSON is broken, the error message tells you what went wrong so you can fix it; otherwise copy the result.
About the JSON Formatter
A JSON formatter takes compact or messy JSON — like a raw API response squeezed onto one line — and reformats it with consistent indentation so it's actually readable, or does the reverse and minifies it down for production use. Along the way it validates the JSON, pointing out exactly why it failed to parse if it's malformed.
This is a common step when debugging an API response, cleaning up a config file, or checking whether a JSON payload someone sent you is actually valid before using it.
Worked example
Example: pasting {\"name\":\"Ana\",\"active\":true} and clicking Format returns it spread across multiple indented lines with each key on its own row — much easier to scan than the single-line version, especially for deeply nested objects.
What happens when you format or minify
The formatter parses your input with the browser's standard JSON parser, then writes it back out — with two-space indentation when you format, or with all optional whitespace removed when you minify. Because the output is rebuilt from the parsed data, formatting also normalizes the text: escape sequences, spacing, and number formats are rewritten in a canonical form.
Three surprises when round-tripping JSON
Rebuilding JSON through JavaScript has side effects worth knowing before you paste the result back into a file:
- Very large integers lose precision. Numbers above 9,007,199,254,740,991 (2⁵³ − 1) can't be represented exactly, so an ID like 12345678901234567890 comes back as 12345678901234567000. If your data has 64-bit IDs, keep them as strings.
- Duplicate keys collapse. If an object has the same key twice, only the last value survives, without any warning.
- Integer-like keys move to the front. JavaScript orders keys such as '1' or '42' numerically before all other keys, so {"b":1,"2":0} is written back as {"2":0,"b":1}. The data is the same, but a diff will show changes.
Reading parse errors
When parsing fails, the error message usually gives a position in the text. Look just before that point: the problem is typically a missing comma between items, a comma after the last item, a missing closing bracket, or an unescaped quote inside a string. Leading zeros (007), the values NaN and Infinity, and comments are also invalid in strict JSON. Fix the first error and format again, since one mistake can cause misleading errors further on.
Frequently asked questions
- Why does it say my JSON is invalid when it looks fine?
- The most common causes are a trailing comma after the last item in an object or array, using single quotes instead of double quotes around keys/strings, or an unescaped quote inside a string — all valid in JavaScript object literals but not in strict JSON.
- What's the difference between formatting and minifying?
- Formatting (beautifying) adds indentation and line breaks to make JSON easy for humans to read. Minifying strips all unnecessary whitespace to make the file as small as possible — useful for production APIs or reducing file size, at the cost of readability.
- Is my JSON data sent anywhere?
- No. Parsing, formatting, and validation all happen locally in your browser using JavaScript's built-in JSON parser — nothing is uploaded to a server, so it's safe to paste sensitive API responses or config data.
- Does this support JSON5 or JavaScript object syntax?
- No, this tool validates strict, standard JSON only (as defined by json.org) — the same format used by REST APIs and config files. Comments, trailing commas, and unquoted keys will be flagged as errors, since those aren't valid JSON.