How to format and validate JSON
- Paste JSON into the input box, open a
.jsonfile, or drag one in. - If the JSON is valid, the formatted version appears on the right with a summary of what it contains.
- If it is not valid, the error message gives the line and column, and the error panel shows the line with a marker under the problem.
- Choose 2 spaces, 4 spaces, tabs or minified output, then copy or download.
Example
Minified input:
{"id":7,"tags":["a","b"],"price":1.50} Formatted with 2 spaces:
{
"id": 7,
"tags": [
"a",
"b"
],
"price": 1.50
} Notice that 1.50 keeps its trailing zero. Many formatters run the input through JSON.parse and print 1.5 instead, and they round integers above 9,007,199,254,740,991.
Common JSON errors and how to fix them
| Message | Usual cause |
|---|---|
| Expected a double-quoted property name | An unquoted key such as {id: 1}, or a trailing comma before }. |
| Trailing comma in array / object | A comma after the last item: [1, 2,]. |
| Single-quoted strings are not valid JSON | Text copied from JavaScript or Python. Replace ' with ". |
| Unescaped control character | A raw line break or tab inside a string. Write it as \n or \t. |
| Unexpected … after the end of the JSON value | Two JSON documents pasted together, or JSON Lines (one object per line). |
| Invalid number (leading zeros) | A number such as 007. Quote it as a string if the zeros matter. |
Limitations
- Only strict JSON (RFC 8259) is accepted. JSON5, comments and JSON Lines are reported as errors.
- If an object repeats a key, both entries are kept in the output and you are warned. Most programs keep only the last one when they read it.
- Maximum input size is 50 MB, and nesting deeper than 1,000 levels is rejected.
Frequently asked questions
Does formatting change my data?
No. Only whitespace changes. Numbers are copied exactly as written (so 12345678901234567890 and 1.50 stay as they are), key order is kept unless you choose to sort, and repeated keys are kept rather than silently dropped.
Why does a JSON validator say my file is invalid when JavaScript accepts it?
JavaScript object syntax is looser than JSON. JSON requires double-quoted keys and strings, and does not allow comments, trailing commas, single quotes, NaN or Infinity. The error message names the problem and shows where it is.
What does "sort keys" do?
It orders the keys of every object alphabetically (by character code), at every level. This makes two JSON documents easier to compare. Arrays are never reordered, because array order is meaningful.
Is my JSON uploaded?
No. Validation and formatting run in your browser. Nothing is sent to a server, so it is safe to format API responses or configuration that contains private values.
What is the largest file I can format?
Up to 50 MB. Files over 2 MB are formatted when you press Format, so typing stays responsive.
Last updated .