JSON Formatter & Validator
Pretty-print or minify JSON in the browser and see syntax errors with line and column details.
Your data stays in your browser. This tool processes your input locally and does not upload it to a server.
Input
Output
What is a JSON formatter and validator?
A JSON formatter re-indents JSON text so people can read it, and a validator checks that it follows the JSON grammar. This tool does both in your browser: paste or upload JSON, press Format, and it either returns tidy output or points to the line and column where parsing failed.
What you can do with it
Format indents the result with 2 spaces, 4 spaces or tabs. Minify removes all insignificant whitespace. Format on paste is on by default, so pasted JSON is formatted immediately; untick it to keep your text as typed. You can also upload a .json or .txt file up to 5 MB, load a sample, copy the result or download it as formatted.json.
The output has a Text view and a Tree view. The tree opens the first level and expands other nodes when you click them or press Enter or Space on the arrow button. Each node shows its key count or item count, and can copy its path (such as $.users[0].name) or its value. Large arrays and objects show 100 children at a time.
How errors are reported
When the input is invalid, the message gives a line and column. Beside it is a short list of possible causes, such as a trailing comma, single quotes, an unquoted key, a comment, a missing bracket or an unterminated string. These hints are guesses made from the error text and the characters near the position, so treat them as a starting point rather than a diagnosis.
Everything runs locally. Your JSON is never sent to a server, and uploaded files are read with the browser file reader only. Output is capped at 1 MB and nesting at 100 levels, and the tool says so instead of calling such input invalid.
Examples
Format compact JSON with 2 spaces
Input
{"name":"FestivKit","tags":["a","b"],"active":true,"empty":{}}Output
{
"name": "FestivKit",
"tags": [
"a",
"b"
],
"active": true,
"empty": {}
}Empty objects and arrays stay on one line.
Minify and keep a large number exact
Input
{
"id": 12345678901234567890,
"ok": true
}Output
{"id":12345678901234567890,"ok":true}The text of the number is copied as written, so no digits are lost. JavaScript itself would round this value when it parses it.
Find a trailing comma
Input
{"a":1,
"b":2,}Output
This is not valid JSON. Trailing comma. Line 2, column 8.The hint list suggests a comma left before the closing brace.
Common mistakes and edge cases
- Trailing commas are not allowed: [1,2,] and {"a":1,} are invalid, even though many programming languages accept them.
- Strings and keys need double quotes. Single quotes and unquoted keys such as {name: 1} are JavaScript object syntax, not JSON.
- JSON has no comments. Remove // and /* */ before validating, or use a format such as JSONC that is processed by a different tool.
- Duplicate keys in one object are rejected here. The specification says names should be unique, and parsers that accept duplicates usually keep only the last value.
- Numbers beyond about 15 to 17 significant digits lose precision once JavaScript parses them. Formatting here keeps the digits, but the Tree view uses JSON.parse, so its displayed numbers can be rounded.
- undefined, NaN, Infinity, True and None are not JSON values. Use null, a string, or lowercase true and false.
How to use this tool
- Paste JSON into the input editor.
- Choose an indentation, then format or minify.
- Copy or download the result. Fix any line and column shown in the error.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Formatting, validation, the tree view and file upload all happen in your browser. The file chooser reads your file locally with the browser FileReader, and the text is never sent over the network. Because the page runs locally, it is a reasonable place to inspect internal or sensitive payloads, although you should still follow your own organisation rules about where secrets are pasted.
Why does my JSON fail when it works in JavaScript?
JavaScript object literals are more lenient than JSON. They allow single quotes, unquoted keys, trailing commas, comments and values such as undefined. JSON, defined by RFC 8259 and ECMA-404, allows none of these. The error hints beside the line and column name the most likely cause, but they are guesses, so check the highlighted position yourself.
What does format on paste do?
When the option is ticked, pasting text into the input editor formats it straight away using the indentation you selected, and shows the result in the output panel. Your pasted text stays in the input unchanged. If the paste is invalid JSON you get the error and its hints instead. Untick the box if you prefer to press Format yourself, for example when assembling JSON from several pieces.
How does the tree view handle large JSON?
The tree only builds the nodes you open. It expands the first level, and each array or object shows its number of items or keys. Long lists reveal 100 children at a time with a button for more. Every node can copy its path or value. The output itself is limited to 1 MB, and the Tree view parses the formatted output with JSON.parse, so very large numbers can appear rounded.
What is the difference between Format and Minify?
Format adds line breaks and indentation so the structure is easy to read. Minify removes every space and line break that is not inside a string, producing the smallest equivalent text, which is useful for payloads and configuration that are stored or sent over a network. Both check the syntax first, so either button doubles as a validator, and the data itself is not changed.
References
Last reviewed