How to use the JSON formatter
- Paste your JSON into the input pane, or press Sample to try an example.
- Press Format to pretty-print, Minify to compress or Validate to check syntax.
- Choose 2 spaces, 4 spaces or tabs, and optionally sort keys alphabetically.
- Copy the result or download it as a .json file. Shortcut — Ctrl/⌘ + Enter formats.
Readable JSON in one click
API responses, config files and logs usually arrive as one long line. Paste them here and Format turns them into neatly indented, readable structure. Minify does the reverse for production payloads, and Validate tells you exactly where a broken document goes wrong.
Features
- Beautify with 2 spaces, 4 spaces or tabs
- Minify to the smallest valid form
- Validate with the error message plus line and column
- Sort keys alphabetically, recursively, to make diffs and reviews easier
- Copy or download as
.json - Private: nothing is sent anywhere
JSON syntax rules at a glance
| Rule | ✓ Valid | ✕ Invalid |
|---|---|---|
| Keys use double quotes | {"a": 1} |
{a: 1}, {'a': 1} |
| Strings use double quotes | "text" |
'text' |
| No trailing commas | [1, 2] |
[1, 2,] |
| No comments | — | // note |
| Literals are lowercase | true, null |
True, NULL |
| Numbers have no leading zeros | 0.5, 10 |
.5, 010 |
Fixing common errors
- “Unexpected token”: usually a single quote, an unquoted key or a stray character. Go to the reported line.
- “Expected ‘,’ or ‘}’”: a missing comma between two properties, often on the line before the reported one.
- “Unexpected end of JSON input”: a missing closing
}or]. Formatting a partial document and checking indentation helps you find it. - Trailing comma: remove the comma after the last item in an object or array.
Format vs. minify — when to use which
Use formatted JSON for config files in version control, documentation and debugging, where people need to read it. Use minified JSON for network payloads and storage, where the whitespace adds bytes but no value. Gzip shrinks both, but minified is still smaller.
For counting characters in a payload or field, use the word counter.
Frequently asked questions
Is my JSON uploaded to a server?
No. Parsing and formatting use your browser's built-in JSON engine, so API keys, tokens and customer data in your JSON stay on your device.
What does JSON formatting do?
Formatting (beautifying or pretty-printing) adds line breaks and indentation so nested objects and arrays are easy to read. The data itself is unchanged.
What does JSON minification do?
Minification removes all unnecessary whitespace to make the JSON as small as possible for storage or transfer. It is still valid, identical data.
Why is my JSON invalid?
The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, comments and missing commas between items. The error message shows the line and column where parsing failed.
Does sort keys change my data?
It changes only the order of keys inside objects, which JSON treats as insignificant. Array order is never changed.