Developer tool
JSON Formatter & Validator
Paste JSON to validate it as you type, beautify it with readable indentation, minify it to one line or sort its keys. Nothing leaves your browser.
In short: A JSON formatter parses your JSON and prints it back with consistent indentation, so nested objects become readable. If the text is not valid JSON, the parser stops at the first error and this JSON validator shows you where. Minify does the opposite and strips every unnecessary space.
Beautify or minify: when to use which
Pretty-printed JSON is for people. Use it when you read an API response, review a config file in a pull request or compare two payloads. Two spaces of indentation is the most common style (it is the default in Prettier and in most API docs); four spaces is typical in Python projects because json.dumps(data, indent=4) shows up in so many tutorials.
Minified JSON is for machines. It removes line breaks and indentation, which typically cuts 15 to 35 percent of the raw size of a nested document. Once a server applies gzip or Brotli the gap shrinks to a few percent, so minifying matters most where compression does not apply: values stored in a database column, localStorage, a URL parameter or a JSON-LD block inlined in HTML.
// Beautified (2 spaces)
{
"id": 1042,
"tags": ["sale", "shoes"],
"inStock": true
}
// Minified
{"id":1042,"tags":["sale","shoes"],"inStock":true}
Common JSON syntax errors and how to fix them
JSON (RFC 8259, ECMA-404) is much stricter than JavaScript object syntax. Almost every "invalid JSON" message comes from one of these:
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | Remove the comment |
| Special numbers | NaN, Infinity, undefined | null |
| Leading zero or plus sign | 007, +5 | 7, 5 |
| Raw line break in a string | A string split across two lines | Use \n inside the string |
The validator uses the browser's own JSON.parse, so its verdict matches what your front-end code will see. Recent versions of Chrome and Edge report the problem as "at position 15 (line 1 column 16)", and Firefox gives the line and column too. The real mistake is usually just before that point. A file that starts with a byte order mark, or text copied from a word processor with curly quotes, fails for the same reason: the parser only accepts straight double quotes.
Why sort JSON keys
Sorting puts object keys in alphabetical order at every level of nesting, while arrays keep their original order because position matters there. Two payloads that hold the same data but were serialized by different code then produce an identical text, which makes a line-by-line diff show only the values that really changed. It also helps when you commit generated JSON to Git: stable key order means smaller, cleaner diffs.
Two details are worth knowing. The sort compares UTF-16 code units, so uppercase letters come before lowercase ones ("Zip" before "city"). And JavaScript always lists integer-like keys such as "2" and "10" first, in numeric order, no matter how they were inserted.
Limits of browser-based JSON parsing
JavaScript stores numbers as 64-bit floats. Any integer above 9,007,199,254,740,991 (253 − 1) is rounded when parsed, so a Twitter-style ID like 1790000000000000123 comes out slightly different after formatting. If your data has IDs that large, keep them as strings. Duplicate keys are legal according to the grammar but JSON.parse keeps only the last one, so the formatted output will silently drop the earlier value. Very large files, roughly 50 MB and up, may make the tab sluggish; a command-line tool such as jq . is the better choice there. Building structured data for a web page? The FAQ schema generator writes valid JSON-LD for you.
Frequently asked questions
How do I find the error in invalid JSON?
Paste it into the input box. The status badge shows the parser's message, which in current Chrome, Edge and Firefox includes the line and column of the first problem. Look just before that position: the cause is usually a missing comma, a trailing comma or a single-quoted string.
Is it safe to paste JSON with API keys into an online formatter?
With this one, yes. Parsing, formatting and minifying all happen in JavaScript in your own browser, and the page sends nothing to a server. As a habit, still remove live secrets from anything you paste into a web page you have not checked yourself.
Does formatting JSON change the data?
Formatting and minifying only change whitespace, with two exceptions caused by JavaScript itself: integers larger than 9,007,199,254,740,991 lose precision, and if an object repeats a key only the last value is kept. Sorting keys changes order but not values.
Related tools: FAQ Schema Generator · Hreflang Generator · Meta Tag Generator