JSON Formatter and Validator
Paste JSON and it is formatted straight away, with colour for every key, value and bracket level. Minify it, sort its keys, or check that it parses: if it doesn't, you get the line and column of the error. It all runs in your browser, so API responses and config never leave your machine.
Formatted JSON shows up here.How to use it
- Paste JSON into the left box and it is formatted straight away. Or press Sample to try it.
- Format indents it with 2 spaces, 4 spaces or tabs. Minify strips every space, for payloads and env vars.
- Tick Sort keys to order keys alphabetically at every level, which makes two JSON files easy to diff.
- If the JSON is invalid, the error names the line and column, and the cursor jumps to that spot in the input.
Why JSON fails to parse
Most invalid JSON is valid JavaScript. These six cause nearly every error you'll see:
Trailing comma
{"a": 1, "b": 2,}Remove the comma after the last item in an object or array. JavaScript allows it; JSON does not.
Single quotes
{'name': 'Ada'}Use double quotes for every key and every string.
Unquoted keys
{name: "Ada"}Keys must be strings in double quotes, even when they look like identifiers.
Comments
{"a": 1 // id}JSON has no comments. Delete them, or move the note into a field.
undefined, NaN or Infinity
{"score": NaN}JSON only has numbers, strings, true, false and null. Use null for a missing value.
Unescaped characters in strings
{"path": "C:\Users"}Escape backslashes as \\ and quotes as \". Raw line breaks inside a string must be \n.
Is my data safe?
Yes. Formatting uses the browser's own JSON.parse and JSON.stringify. Nothing is uploaded, logged or stored, so it is safe for tokens, customer records and production config. You can turn off your network after the page loads and it still works.