What is JSON?
JSON, short for JavaScript Object Notation, is a lightweight text format for exchanging data. Web APIs, configuration files, databases and mobile apps use it everywhere, because it is easy for people to read and for programs to parse. A JSON document is built from objects in curly braces, arrays in square brackets, strings in double quotes, numbers, true, false and null.
JSON from an API is often sent on a single line to save space, which makes it very hard to read. A formatter, also called a beautifier or pretty printer, adds line breaks and indentation so the structure is visible. A validator checks that the text follows the rules, so that programs can read it without errors.
How to format and validate JSON
- Paste your JSON into the input box.
- Choose the indentation: 2 spaces, 4 spaces or a tab.
- Press Format to beautify it, Minify to remove all spaces, or Validate to check it without changing it.
- Tick Sort object keys A-Z if you want a predictable key order.
- Copy the result or download it as a .json file.
Format, minify and validate: what is the difference?
- Format makes JSON readable by adding line breaks and indentation. Use it while you debug or review data.
- Minify removes all unnecessary whitespace so the file is as small as possible. Use it for production files and API payloads.
- Validate only checks whether the text is valid JSON and tells you what it contains.
- Sorting keys puts object properties in alphabetical order, which helps when you compare two files.
Finding JSON errors
JSON is strict. A single missing comma or an extra quote makes the whole document invalid. When the text cannot be parsed, this tool shows the message from the browser's JSON parser together with the line and the column where the problem was found, so you can jump straight to the spot. The error is usually at, or just after, the position shown.
JSON compared with other formats
- JavaScript objects allow single quotes, unquoted keys and trailing commas. JSON does not.
- JSON does not allow comments. If you need comments in configuration, formats such as YAML or JSON with comments may fit better.
- XML is more verbose than JSON, but it supports attributes and schemas.
- CSV is flat and compact, but it cannot describe nested data.
Big numbers, precision and Unicode
JSON itself has no limit on the size of a number, but many programs, including JavaScript, read numbers as 64-bit floating point values, which are exact only up to 9,007,199,254,740,991. IDs longer than that, such as some database keys, should be sent as strings so that no digits are lost. JSON also allows non-English text directly, and it can write any character as a sequence such as backslash u followed by four hex digits. Both forms mean the same thing.
Common JSON errors and how to fix them
| Error | Fix |
|---|---|
| Trailing comma after the last item | Remove the comma before the closing bracket or brace |
| Single quotes around strings | Use double quotes for keys and strings |
| Unquoted property names | Put property names in double quotes |
| Comments in the file | Remove them. JSON has no comment syntax |
| undefined, NaN or Infinity | Use null or a number. These values are not valid JSON |
| Missing comma between items | Add a comma between properties and array items |
Frequently Asked Questions
How do I format JSON?
Paste the JSON and press Format. The tool adds indentation and line breaks.
How do I validate JSON?
Press Validate. If the JSON is valid you see a confirmation, otherwise you see the error and its position.
Can JSON have comments?
No. Standard JSON does not support comments.
Why is my JSON invalid?
Common causes are trailing commas, single quotes, unquoted keys and missing commas. The error message shows where the parser stopped.
What does minify do?
It removes all whitespace between tokens, making the JSON as small as possible without changing its meaning.
Is my JSON uploaded?
No. Formatting and validation run in your browser, so private data stays on your device.
Is there a size limit?
No fixed limit. Very large files of tens of megabytes may be slow, depending on your device.