JSON Formatter, Validator & Viewer
Format, validate, minify and explore JSON as a collapsible tree. Errors show the exact line, column, cause and fix, and numbers stay exactly as written.
How to Use
- Choose a mode: Format (pretty-print), Validate (find and explain errors), Minify (one line) or Tree (collapsible view with search).
- Paste JSON or drop a .json file of up to 20 MB. The result updates as you type.
- Pick the indent (2 spaces, 4 spaces or a tab), tick Sort keys for stable diffs, or Relaxed to accept comments and trailing commas.
- If the JSON is invalid, the error box shows the line, column, cause and fix; Jump to the error selects the exact character in your text.
- In Tree mode, click ▸ to open a node, search keys and values, and click any row to see its path, such as
$.users[0].email. - Press Copy result, or Use as input to keep editing the formatted text.
Worked Example
Format {"name":"Ada","langs":["en","fr"],"admin":true} (47 bytes) with a 2-space indent.
Parse: an object with 3 keys. The value of “langs” is an array of 2 strings, so the deepest container is $.langs and the depth is 2. There are 6 values in all: 1 object, 1 array, 3 strings and 1 boolean.
Write: every key goes on its own line, indented 2 spaces per level, so the array items get 4. That adds 7 line breaks, 16 indent spaces and a space after each of the 3 colons: 7 + 16 + 3 = 26 bytes, so 47 → 73 bytes over 8 lines. Minify reverses it: 73 → 47 bytes (−35.6%).
Validate this four-line object: { "name": "Ada", "langs": ["en", "fr"], } with the closing brace on line 4. The parser stops at line 4, column 1: the comma at the end of line 3 has no item after it. Delete it, or tick Relaxed, and it parses.
The common mistake: formatting with JSON.stringify(JSON.parse(text)), which is what most formatters and console one-liners do. It quietly changes data: {"id": 9007199254740993, "price": 1.50} comes back as {"id":9007199254740992,"price":1.5}, because every number becomes a 64-bit double and 253 + 1 = 9,007,199,254,740,993 has no exact double. This tool keeps every number exactly as written and flags the ones JavaScript would round.
Show Work
JSON Rules
Where JSON Came From
JSON was not so much invented as noticed. Around 2001, Douglas Crockford and his colleagues at State Software were passing data between browser and server as JavaScript object literals, and Crockford wrote down the small subset that any language could parse, published the grammar at json.org, and gave it a name. Its whole syntax fits on a business card: objects, arrays, strings, numbers, true, false and null.
Crockford described it in RFC 4627 in July 2006. ECMA-404 followed in October 2013, RFC 7159 in March 2014, and the current RFC 8259 and ISO/IEC 21778 in December 2017. Comments were left out on purpose; Crockford said he removed them because people were using them to hold parsing directives, which would have broken interoperability. That is why JSON5 (2012) and the “JSON with comments” used by VS Code and TypeScript’s tsconfig.json exist as separate, looser dialects.
RFC 8259 also explains two of this tool’s warnings: names within an object SHOULD be unique, because parsers disagree about duplicates, and only integers within ±(253 − 1) are guaranteed to mean the same thing everywhere.
About This Tool
This tool pretty-prints, validates, minifies and browses JSON in one place; it replaces the separate JSON Validator and JSON Tree Viewer. It uses its own strict RFC 8259 parser rather than the browser’s, so every browser reports the same error with the same line and column, explains the likely cause (trailing comma, single quotes, Python’s True and None, curly quotes pasted from a document, a non-breaking space), and never rounds a number or drops a duplicate key behind your back.
Relaxed mode strips comments and trailing commas without moving anything, so error positions still match your text. Tree mode draws only the nodes you open and searches every key and value, which keeps a 20 MB file usable. Everything runs in your browser; nothing you paste or drop is uploaded.
Related tools: JSON to TypeScript, JSON ⇄ CSV Converter, and YAML ↔ JSON Converter.
Frequently Asked Questions
Why won’t my JSON parse?
The usual causes are a comma after the last item ({"a":1,} fails at line 1, column 8), single quotes, keys without quotes, comments, and Python output such as True or None. The error box names the cause, shows the line with a caret under the exact character, and says how to fix it. Jump to the error selects that character in your text.
How are the line and column counted?
Both start at 1. The line is one more than the number of line breaks before the error, and the column counts characters from the start of that line, so a tab counts as one. Minified JSON is all on line 1, where the column can run into the millions, so the error box shows a 100-character window around it.
Why does 9007199254740993 change in other formatters but not here?
Most formatters run JSON.parse and JSON.stringify, which turn every number into a 64-bit double. Doubles hold every integer only up to 253 − 1 = 9,007,199,254,740,991, so 9007199254740993 comes back as 9007199254740992 and 1.50 as 1.5. This tool has its own parser that keeps each number exactly as typed, and Show Work warns when a number would lose precision in JavaScript. It is why APIs such as Twitter’s send large IDs as strings too.
What does Relaxed accept?
Comments (// and /* */) and trailing commas: the JSON-with-comments style used by VS Code settings and tsconfig.json. They are blanked out with spaces before parsing, so line and column numbers still match your text, and the output is strict JSON without them. Single quotes, unquoted keys and other JSON5 extras are still reported as errors.
How large a file can it handle, and is it uploaded?
Up to 20 MB of text. An 11.7 MB array of 200,000 objects parses in about half a second on a recent laptop. The tree only draws the nodes you open, 500 children at a time, so large arrays stay responsive. Nothing is uploaded: parsing, formatting and searching all run in your browser.
How do I use the JSON Formatter, Validator & Viewer?
Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.
Does it cost anything or need an account?
No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.
Is anything I type uploaded?
No. The tool works entirely on your device, so the values you enter never leave your browser.
Common Use Cases
Reading API responses
Paste a one-line response from curl or DevTools: the 181-byte users sample becomes 25 readable lines, 4 levels deep.
Fixing a broken config
A build fails on a JSON file? Validate shows “Trailing comma · line 4, column 1”, why it is wrong, and selects the character.
Clean diffs
Sort keys and use the same indent on both versions, so a text diff shows real changes instead of reordered keys.
Smaller payloads
Minify before putting JSON in a URL, header or HTML attribute: the sample package.json drops from 157 to 116 bytes (−26.1%).
Finding one field
Switch to Tree and search “isbn” to jump straight to $.store.book[1].isbn in a nested response.
Checking JSONC files
Tick Relaxed to validate tsconfig.json or VS Code settings with their comments; the output is the same data as strict JSON.
Last updated: