What JSON is and why it needs formatting
JSON stands for JavaScript Object Notation. It is a plain text format for data, used by web services, apps and configuration files. A JSON document is built from objects (pairs of a key and a value inside curly braces), arrays (lists inside square brackets), strings, numbers, true, false and null.
Computers do not care how JSON looks, so it often arrives as one long line with no spaces. That is hard for a person to read. A formatter adds line breaks and indentation so the structure is visible. A validator tells you whether the text follows the rules at all. This page does both, and it can also minify, which removes the extra spaces again.
Format, minify and validate
Format rewrites the JSON with one item per line and the indentation you choose: 2 spaces, 4 spaces or a tab. Empty objects and arrays stay on one line as and [].
Minify removes every space and line break that is not inside a string. The result is the shortest form of the same data, which is handy for sending it in a request or storing it in a small field.
Validate only checks the text and shows the statistics. It does not change anything.
None of these actions changes your data. Numbers are copied exactly as you wrote them, so a long number such as 12345678901234567890 is not rounded, 1.0 stays 1.0, and the order of keys stays the same. Text inside strings is not touched either.
Sort keys
Tick Sort keys to put the keys of every object in alphabetical order. The tool compares keys by character code, so capital letters come before small letters, and numbers written as keys are compared as text. Arrays keep their order, because the order of items in a list usually has meaning. Sorting keys is useful when you want to compare two JSON files, or keep a configuration file tidy.
Very deep nesting is the only limit here. If the JSON is nested more than 1,000 levels deep, the tool still formats and minifies it, but it will not sort it, and says so.
Understanding error messages
When the JSON is not valid, the tool shows the line and column of the first problem, the text of that line with a marker under the spot, and a short hint when the mistake is a common one. The position is the place where the parser noticed the problem, which can be just after the real mistake. If a closing bracket is reported, look at the item before it.
Typical mistakes are:
- A comma after the last item. JSON does not allow it, so remove the comma before the closing bracket.
- Single quotes. Strings and keys must use double quotes.
- Keys without quotes. Write "name", not name.
- Comments. Standard JSON has no comments, so lines starting with // or # are errors.
- A missing comma between two items, or a missing colon after a key.
- A missing bracket or quote at the end, which the tool reports as the JSON ending too soon.
- A line break inside a string. Write it as \n instead.
Different browsers describe problems in different words, and some give no position at all. When that happens, this tool finds the first problem itself, so you still get a line and column.
The statistics
After you click a button you see four facts. Status says whether the JSON is valid. Size before and Size after are measured in bytes, so a character such as é counts as two and an emoji as four, which is how the text is stored in a file. Top level tells you what the JSON contains at its outermost level, for example an object with 5 keys or an array with 120 items. If an object repeats a key, the count includes it once, since that is how a parser reads it.
Size limit
You can paste up to 500,000 characters. JSON takes more work to check and print than plain text, so this limit is lower than the one for the other text tools. If you paste more, the tool keeps the first 500,000 characters and shows a message. The work runs only when you click a button, so typing and pasting stay smooth, even with a large document. For very large files, split the data into parts.
Safety and privacy
The tool checks your text with the JSON parser built into your browser. It never runs your text as code, so a document that looks like a script cannot do anything here. Your JSON stays on your device. It is not uploaded, stored or tracked, and there is no sign-up. Like every page on this site, this one may show ads from third-party vendors once ads are switched on, and those vendors can use cookies. Read the privacy policy for details.
Tips
- Format first, then read the structure. Most mistakes become obvious once each item has its own line.
- Use the text case converter to change the case of key names, and the remove duplicate lines tool to clean a list you copied out of JSON.