What it does
The input is parsed and written back out with the indentation you choose, or minified onto one line with all insignificant whitespace removed. If the input isn't valid JSON you get the error message and the line and column where parsing stopped; click the location to put the cursor there.
Common JSON errors
- Trailing comma —
[1, 2, 3,]or{"a": 1,}. Not allowed in strict JSON. - Single quotes — JSON strings and keys must use double quotes:
{"name": "Ann"}, not{'name': 'Ann'}. - Unquoted keys —
{name: "Ann"}is valid JavaScript but not JSON. - Comments — JSON has no comments. Files like
tsconfig.jsonuse "JSON with comments", which this tool accepts when Allow comments & trailing commas is on; the output is always strict JSON. - Special values —
NaN,Infinity,undefinedand dates are not JSON values. Usenull, strings or numbers. - Unescaped control characters — a literal tab or line break inside a string must be written as
\tor\n.
Options
- Sort keys orders object keys alphabetically at every level — useful before committing config files, or before comparing two documents (the JSON diff does this for you).
- Minify is handy for embedding JSON in an environment variable, a URL parameter (after Base64 encoding) or a test fixture.
Is my data uploaded?
No. Formatting runs in your browser, so nothing you add is sent to gratistools.be. See the privacy page for details.