Format or validate your JSON
Paste your JSON in the box, pick an indent size, then click one of the buttons.
Result
Here is your processed JSON. Click the button to copy it.
What Is JSON?
JSON stands for JavaScript Object Notation. It is a plain text format for storing and exchanging structured data. Almost every web API, config file and log pipeline today speaks JSON because it is small, easy for people to read and easy for programs to parse.
The six JSON value types
- Object: an unordered set of key and value pairs wrapped in curly braces. Keys must be strings in double quotes.
- Array: an ordered list of values wrapped in square brackets.
- String: text in double quotes. Single quotes are not allowed.
- Number: an integer or decimal. No leading zeros, no hex, no NaN or Infinity.
- Boolean: the literal words
trueorfalse, always lowercase. - Null: the literal word
null.
Why format JSON?
Servers usually send JSON with all whitespace stripped to save bandwidth. That is great for machines and terrible for humans. Formatting, also called pretty printing or beautifying, adds line breaks and indentation so you can see the structure at a glance, spot a missing field, or diff two responses. Minifying is the reverse: it removes every unneeded space so the text is as short as possible before you store or send it.
Common JSON mistakes this tool catches
- Trailing commas:
{"a": 1,}is valid JavaScript but not valid JSON. - Single quotes:
{'a': 1}fails. JSON only accepts double quotes. - Unquoted keys:
{a: 1}fails. Every key must be a quoted string. - Comments: JSON has no comment syntax. Lines starting with
//or blocks in/* */are errors. - Undefined and functions: these JavaScript values have no JSON form and cannot appear in the text.
- Unescaped control characters: a raw line break inside a string must be written as
\n.
JSON vs a JavaScript object
People often mix the two up. A JavaScript object lives in memory and can hold functions, dates and undefined. JSON is only text. When you call
JSON.stringify the object is turned into text, and JSON.parse turns that text back into an object. The rules of JSON are stricter than
JavaScript, which is why code that looks fine in a script can still fail as JSON.
How this tool works
The formatter uses your browser's built in JSON.parse and JSON.stringify. If parsing fails, the error message includes the line and
column where the parser stopped so you can jump straight to the problem. The Sort Keys button walks the whole structure and orders every object's keys
alphabetically, which makes two documents much easier to compare side by side. Nothing you paste ever leaves your computer.