JSON formatter and validator
Paste JSON and it is parsed by the browser’s own JSON.parse, then pretty-printed or minified for download. If the text is invalid you get the parser’s message and the error’s line and column. The tool never repairs anything on its own. It works as a JSON beautifier and a JSON validator at the same time.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Paste your JSON into the input box, or press “Load example”.
- Choose “Format” with an indent (2 spaces, 4 spaces or tab), or “Minify” to strip whitespace.
- Tick “Sort keys alphabetically” if you want a stable key order at every level.
- If an error appears, read the line and column, press “Go to the error position” and correct it yourself.
- Copy the result or download it as a .json file.
Example
The text {"b":[1,2],"a":{"c":null}} formatted with 2 spaces becomes nine lines starting with {, then "b": [ and so on, and grows from 26 bytes to 57 bytes. Depth is 2 and there are 3 keys.
The three-line text { then "a": 1, then } is invalid because of the trailing comma. The tool reports the error at line 3, column 1: the closing } where a property name was expected.
Limits and caveats
- The limit is 5 MB. Measured in Chromium on a desktop computer: a 5 MB file (about 62,000 items) was parsed, formatted and displayed in about 3 seconds. Larger files are refused.
- The browser’s edit box gets slow with long texts (we measured about 4 seconds per megabyte of pasted Arabic text). Open large files with “Open a JSON file” instead: anything over 200,000 characters is processed from memory and only the first 200,000 characters of the output are displayed, while copy and download include the full output.
- Invalid JSON is never repaired: comments, single quotes, trailing commas, NaN and unquoted keys are all errors under RFC 8259.
- Integers above 9007199254740991 lose precision in JavaScript when rewritten; the tool warns about them. Store such values as strings if they are identifiers.
- When a key is repeated inside the same object only the last value survives; the tool lists the duplicate keys. Numbers are rewritten in their shortest form (1.50 becomes 1.5).
- The parser message comes from your browser, in English, and differs between browsers. When it has no position, the tool finds it by scanning the text.
- In the text boxes, a line that mixes Arabic with numbers can look reordered on screen. That is how browsers display bidirectional text; the data itself is in the correct order when copied or downloaded.
- Columns are counted in UTF-16 units and the ^ marker may not sit exactly under the character on a line containing Arabic text, so the offending character is also highlighted.
Questions about this tool
Does the tool change Arabic text or turn it into \uXXXX escapes?
No. Arabic keys and values and emoji are kept as they are. If the source used an escape such as \u0645, the output shows the character itself (م), because both are the same value in JSON.
Why does the error point at the closing } and not at the trailing comma?
The parser reads the comma, then expects another property name and finds } instead. The reported position is the first character where the text stopped being valid; the cause is usually just before it.
Does “Sort keys” reorder array items?
No. Only object keys are sorted, at every level. Array items keep their order because that order is part of the data.
How do I validate JSON?
Paste the JSON or open the file with “Open a JSON file”: valid JSON is formatted and its statistics are shown, and invalid JSON shows the parser message with the line and column of the error. For example, {"a": 1,} is invalid because of the trailing comma before the brace. Validation follows strict JSON (RFC 8259), so comments and single quotes are errors too.
How do I beautify minified JSON?
Paste it and choose “Format” with an indent of 2 spaces, 4 spaces or a tab; only the layout changes, never the data. {"a":1,"b":[1,2]} is 17 bytes minified and becomes 7 lines and 39 bytes when formatted with 2 spaces. Choose “Minify” to turn it back into one compact line.
