How to use the JSON formatter
- Paste your JSON — an API response, a configuration file, a log entry — into the box. It is checked and formatted as you paste.
- Choose Format for readable JSON indented with 2 spaces, 4 spaces or tabs, or Minify to remove every space and line break between values.
- Tick Sort keys to put the properties of every object in alphabetical order, which makes two versions of the same data easy to compare. Arrays keep their order.
- Press Copy beside the result. If the JSON is invalid, you get the problem, its line and column, and the line itself with a ^ under the spot.
What formatting, minifying and validating do
Formatting — also called beautifying or pretty-printing — puts each property and list item on its own line and indents it by how deeply it is nested. Minifying does the opposite and leaves the most compact form. Neither changes the data. Validation checks the text against the JSON standard (RFC 8259, the same grammar as ECMA-404), whose rules every JSON parser enforces: names and strings in double quotes, no trailing commas, no comments, lowercase true, false and null, and numbers without leading zeros, NaN or Infinity. It reports the first error it finds.
Many online formatters run your text through JavaScript’s JSON.parse and print it again. This one reads the text itself and keeps every value exactly as written:
- Large numbers aren’t rounded. JavaScript stores whole numbers exactly only up to 9,007,199,254,740,991 (253 − 1). Through
JSON.parse, an ID such as 12345678901234567890 becomes 12345678901234567000. Here it stays as it is, and so do 12.50 and 1E+2. - Key order is kept. JavaScript objects list keys that look like whole numbers (“1”, “2”) first, so
JSON.parsemoves them; here the order changes only when you sort. - Strings are copied character for character, including escapes such as
\u00e9and\/. - Duplicate keys are counted. RFC 8259 says names within an object should be unique, because programs disagree about which of two values wins.
Common JSON errors and how to fix them
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Ana'} | {"name": "Ana"} |
| Property name without quotes | {name: "Ana"} | {"name": "Ana"} |
| Comment | {"port": 80 // web} | {"port": 80} |
| Missing comma | [1 2 3] | [1, 2, 3] |
| Curly quotes from a word processor or chat | {“a”: 1} | {"a": 1} |
| Python or JavaScript values | {"x": None, "y": True, "z": undefined} | {"x": null, "y": true, "z": null} |
| Leading zero | {"zip": 02134} | {"zip": "02134"} |
| Single backslash | {"path": "C:\Users"} | {"path": "C:\\Users"} |
| Several values one after another | {"a": 1} {"b": 2} | [{"a": 1}, {"b": 2}] |
When a closing bracket is missing, the parser only notices at the very end, so “Unexpected end of JSON” points at the last line even though the missing } or ] belongs further up. Formatting the part that is valid and looking at where the indentation stops making sense is the fastest way to find it.
Worked example: how much indentation adds
The sample in the box is a 206-byte, one-line API response with 14 keys nested 4 levels deep. Formatted, it grows to 23 lines:
| Output | Size |
|---|---|
| Minified | 206 bytes |
| Tabs | 300 bytes |
| 2 spaces | 358 bytes |
| 4 spaces | 474 bytes |
Tabs keep formatted JSON smallest because each level costs one byte. For files that people read and edit, the readability is usually worth the extra bytes; minify JSON you send or store in bulk.
Limits and tips
- Big files: a 1 MB document is checked and formatted in about a second on a typical laptop, and the long result scrolls smoothly. For files of many megabytes, a command-line tool such as jq is more comfortable.
- JSON Lines (NDJSON) files hold one JSON value per line. They aren’t a single JSON document, so paste one line at a time, or wrap the lines in
[ ]with commas between them. - JSON5 and “JSON with comments”, used by some configuration files, allow comments and trailing commas. Standard JSON doesn’t, so those show as errors here.
- Only the first error is shown. Fix it and the next one, if any, appears straight away.
- Need to change the case of keys, such as camelCase to snake_case? The case converter does that, and the character counter measures strings in characters and bytes.
Your JSON stays on your device
Formatting and validation run in your browser. JSON often holds API keys, tokens or customer records, and none of it is uploaded or logged. It is not saved either: reloading the page clears it.
Frequently asked questions
Is my JSON sent to a server?
No. The page formats and validates it with JavaScript in your browser, so it works with private data and even offline once the page has loaded.
Why is my JSON invalid when it works in JavaScript?
JavaScript object literals allow things JSON does not: unquoted property names, single quotes, trailing commas, comments, undefined and functions. JSON is a stricter data format so that every language can read it the same way.
What does “Unexpected end of JSON” mean?
The text ended while something was still open — usually a missing } or ], or a string without its closing quote. It can also mean the text was cut off when it was copied.
Does sorting the keys change my data?
No. RFC 8259 defines an object as an unordered collection of name/value pairs, so the order of keys carries no meaning. Arrays are ordered, so their items are never sorted.
What is the difference between a JSON formatter, beautifier and validator?
They are names for the same job: a formatter or beautifier makes JSON readable, and a validator checks it against the standard. This page does both at once — invalid JSON is never formatted, so a formatted result is also valid.
Last updated: October 15, 2026