JSON formatter and validator
Paste JSON to check it, pretty-print it with your choice of indent, sort keys, or minify it to one line. Your data never leaves your browser, so it is safe to use with API responses and config files.
What the validator checks
JSON (JavaScript Object Notation) has a short, strict set of rules, defined in RFC 8259. The most common reasons a file fails are:
- Single quotes. Strings and property names must use double quotes:
{"a": "b"}, not{'a': 'b'}. - Trailing commas.
[1, 2, 3,]and{"a": 1,}are not allowed, even though JavaScript accepts them. - Unquoted property names.
{a: 1}is JavaScript, not JSON. - Comments.
//and/* */comments are not part of JSON. - Raw line breaks inside strings. Use
\ninstead. - Special values.
undefined,NaNandInfinityare not valid; usenullor a number.
When something is wrong, the tool shows the line and column of the first problem and what it expected there, so you can jump straight to it.
Worked example
This input:
{"name": "Sam", "tags": ["a", "b"],}
fails with "Trailing comma is not allowed" at line 1, column 36, which is the } right after the last comma. Remove that comma and Format gives:
{
"name": "Sam",
"tags": [
"a",
"b"
]
}
Minify turns it back into {"name":"Sam","tags":["a","b"]}, which is the smallest valid form.
FAQ
Is my JSON sent to a server?
No. Parsing and formatting use your browser's own JSON engine. You can disconnect from the internet after the page loads and it still works.
Does "Sort keys" change my data?
It only changes the order of keys inside objects. The values and the order of items in arrays stay the same. Most programs ignore key order, but some do not, so keep the original if you are unsure.
Are very large numbers safe?
Numbers are read as standard double-precision values. Integers bigger than 9,007,199,254,740,991 (such as some IDs) can lose their last digits when formatted. Keep such IDs as strings.
Are duplicate keys reported?
No. JSON allows them on paper, but most programs keep only the last one, and so does this formatter.