Format, minify or validate: which one you need
The three modes answer different questions, and the same text can need all of them in turn.
- Format adds line breaks and indentation so a person can read nested data. Use it to inspect an API response, a log line or a config file.
- Minify removes every space and line break that is not inside a string. Use it when size matters, such as a request body, an environment variable or a value stored in a URL. The JSON minifier page covers what is and is not removed.
- Validate checks the syntax and reports what is in the document without rewriting it. The JSON validator page explains what that check covers.
Why your numbers are not rounded
Many tools read JSON into JavaScript values and write it back. That quietly changes data. JavaScript numbers are 64 bit floating point values, so an integer above 9,007,199,254,740,991 cannot be stored exactly, and 1.0 comes back as 1.
This formatter reads the text itself and copies each number and string as you wrote it. Only the white space around them changes. Escapes such as \u00e9 stay as typed, and duplicate keys are kept and reported rather than dropped.
If a number has more digits than a JavaScript number can hold, you get a note, because a program that reads that JSON with JSON.parse will round it. IDs that must stay exact are safer written as strings.
What the error messages mean
JSON is stricter than the JavaScript it came from. These are the problems people hit most, and how they show up here:
- A comma is missing before this property. Two values sit side by side. The cause is usually at the end of the previous line.
- Trailing comma. A comma after the last item. It is allowed in JavaScript but not in JSON.
- Property names must be in double quotes. Single quotes and bare names such as
{name: 1}are JavaScript, not JSON. - Comments are not allowed. Standard JSON has no comments. Turn on the relaxed option for files such as
tsconfig.json. - True must be written in lowercase. Python's
True,FalseandNone, and JavaScript'sundefinedandNaN, are not JSON values. - Extra content after the end. A file with one JSON value per line (JSON Lines) is not one document. Put the lines in an array with commas between them.
Large files and key sorting
Up to 2 million characters the result updates while you type. Longer text waits for the Format now button, so the page does not freeze while you paste. How long a big file takes depends on your device.
Sorting orders property names by character code, so capital letters come before lowercase ones, and it applies at every level. The order of items inside arrays is never changed. Sorted output is handy for comparing two objects that list the same keys in a different order.