JSON Formatter & Validator — Free Online JSON Beautifier
Format, validate, minify, repair, and explore JSON data. Fix malformed JSON automatically, navigate with a collapsible tree view, and search within your data. Works with any valid JSON input. 100% client-side — your data stays private.
What does a JSON formatter do? A JSON formatter parses a document and re-prints it with consistent indentation and one key or array element per line, so the nesting becomes visible. Validation comes with it: text that does not conform to RFC 8259 fails to parse, and you get the position of the first offending character instead of formatted output. The result is the same document laid out differently, not an edited one.
How to Use the JSON Formatter
-
Paste, drop or upload your JSON — Type into the left panel and it re-formats about a third of a second after you stop. You can also drag a
.jsonfile anywhere onto the tool, or use the upload icon in the panel header. - Choose an indent width — 2, 4, 8 spaces or a real tab character. The setting applies immediately and is what Download and Copy will hand you.
- Read the status tag and the stats bar — The tag beside the output reads Valid JSON, Minified or Invalid JSON. Below the panels, the bar reports the root type, a recursive count of keys and array elements, the maximum nesting depth and the minified size in bytes.
- Switch to Tree view for deep structures — Tree renders every object and array as a collapsible node labelled with its child count, which is far easier to navigate than 4,000 lines of indented text. Strings longer than 120 characters are shown truncated.
- Search inside the formatted text — The search box highlights every case-insensitive match of your term in the Pretty output. It searches the formatted text, so it matches keys and values alike — switch back from Tree view to use it.
- Repair, then re-check — Repair rewrites the input in place to strip comments and trailing commas and to fix quoting. It tells you what it changed; read that list and the result before trusting it, because the rewrite is textual and can damage strings.
How the Formatter Works
Formatting is a round trip through a parser, not a clever regular expression. The tool runs your text through
JSON.parse to build a real value, then serialises that value back to text with the indent you selected:
Doing it that way is what makes validation free. There is no separate "check" step — if JSON.parse throws,
the input is not valid JSON under RFC 8259, and the browser's own error message is shown verbatim,
including the character position and, in current browsers, the line and column. Minify is the identical round trip with
the indent argument omitted, which is why a document has to be valid before it can be minified.
The consequence worth understanding is that the output is re-printed from the parsed value, not patched from your original text. For a well-formed document that difference is invisible. In a handful of edge cases it is not.
| Input | Comes back as | Why |
|---|---|---|
1.0, 1e3, 0.50 | 1, 1000, 0.5 | Numbers are re-serialised from the parsed double, so the shortest form that round-trips is used |
12345678901234567890 | A slightly different number | JSON numbers become IEEE-754 doubles, which hold integers exactly only up to 2⁵³−1. Send very large IDs as strings |
{"id": 1, "id": 2} | {"id": 2} | A repeated key overwrites the earlier one during parsing, so a duplicate-key bug becomes invisible |
{"10": "a", "2": "b"} | {"2": "b", "10": "a"} | Keys that look like array indices are ordered numerically first. JSON objects are unordered by definition, so this is legal — but surprising |
"café" | "café" | Escapes are decoded on parse and only re-escaped where the grammar requires it |
| Comments, trailing commas | A parse error | Neither is part of JSON. Use Repair first |
Pretty view, Tree view and search
Pretty is the indented text with keys, strings, numbers, booleans and nulls coloured by a regular expression that runs over the serialised output. Tree walks the parsed value instead and builds a collapsible node for every object and array, each labelled with how many keys or items it holds — the fastest way to answer "what shape is this?" for a payload you have never seen. Long strings are cut at 120 characters in the tree, so use Pretty view when you need to read a full value.
The search box highlights matches in the Pretty output only; it has no effect while Tree view is showing. It is a plain case-insensitive substring match against the formatted text, which means it finds keys and values equally and will also match inside a longer word. To locate the path to a specific value rather than every occurrence of a word, the JSON Path Finder is the better tool.
Reading the statistics bar
- Type — whether the root value is an Object, an Array or a bare scalar.
- Keys — a recursive total that counts object keys and array elements at every level, so a 100-item array of 5-key objects reports 600, not 100.
- Depth — the deepest nesting level. A flat object is 1; a scalar is 0.
- Size — the UTF-8 byte length of the minified form, so it does not move when you change the indent. It is the number to quote when discussing payload size, since indentation is not usually sent over the wire.
What Repair Does, and Where It Bites
Repair is a textual clean-up applied to the input box before parsing, aimed at the four ways hand-written or JavaScript-flavoured data drifts out of the JSON grammar. It runs five passes in order and then reports which ones fired:
- Strip
//line comments. - Strip
/* … */block comments. - Convert single-quoted keys and string values to double quotes.
- Remove commas that sit immediately before a
}or]. - Wrap bare identifier keys such as
name:in double quotes.
Because those passes are regular expressions rather than a parser, they cannot tell a comment from a string that merely
looks like one. Two failure modes are common enough to name. A URL inside a value —
"site": "https://example.com" — contains a //, so the comment pass truncates the line and
leaves an unterminated string. And an apostrophe inside a value, as in 'it's fine', breaks the
single-quote conversion. Both leave the document worse than it started.
Treat Repair as a suggestion. It rewrites the left-hand panel in place, so read the list of what it changed and skim the result before you copy it anywhere. If the input contains URLs, run the other fixes by hand instead — or paste the original again and edit the one real error the parser pointed at.
Why JSON Is So Strict
Most invalid-JSON reports come from the same short list, and all of them are things JavaScript object literals allow but
the JSON grammar does not. Keys must be double-quoted strings — not bare identifiers, not single-quoted. Strings must use
double quotes. No comments of any kind. No trailing comma after the last member of an object or array. No
undefined, no NaN, no Infinity, no hexadecimal or leading-zero numbers, and no
single-quoted characters anywhere.
That severity is deliberate. RFC 8259 describes a wire format meant to be parsed identically by every implementation on every platform, so every optional convenience is a place where two parsers could disagree. The looser dialects exist for files humans edit: JSON5 adds comments, trailing commas, unquoted keys and single quotes; JSONC adds just comments and trailing commas and is what VS Code uses for its settings files. Neither is accepted here, which is exactly what makes this page a useful check before you commit a file that a strict parser will have to read.
One more format worth distinguishing: NDJSON or JSON Lines, where each line is its own complete document.
A whole NDJSON file is not one JSON value, so it will not parse. Wrap the lines in [ and ] and
separate them with commas to inspect the set as an array.
Frequently Asked Questions
In order of frequency: a trailing comma before a closing brace or bracket, single quotes instead of double quotes, an unquoted key, a comment, or a missing comma between two members. The browser's parser reports the character position of the first problem — and on current browsers the line and column too — so start there rather than reading the whole file. Everything after that point is unchecked, so fixing one error often reveals the next.
It strips // and /* */ comments, converts single-quoted keys and values to double quotes, deletes trailing commas, and quotes bare identifier keys. It works on the raw text with regular expressions, so it cannot see string boundaries: a URL in a value gets truncated at its //, and an apostrophe inside a single-quoted string breaks the conversion. It also rewrites your input box in place, so check the result before relying on it.
Pretty is syntax-highlighted text with your chosen indentation — good for reading values in full, copying and diffing. Tree is an interactive outline built from the parsed value, where every object and array is a collapsible node labelled with its child count — good for finding your way around a large or unfamiliar payload. Two limits on Tree: strings are truncated at 120 characters, and the search box does not highlight in it.
It re-prints the parsed value rather than reflowing your text, so a few things normalise. Numbers come back in their shortest equivalent form (1.0 becomes 1), integers beyond 2⁵³−1 lose precision, a repeated key collapses to its last value, and keys that look like array indices are reordered numerically. For ordinary documents none of this is visible; for very large IDs or duplicate keys it matters.
No fixed limit — the constraint is your browser's memory and how long you are willing to wait. Everything is held at once: the raw text, the parsed value and the formatted string. API responses and config files are never a problem. Multi-megabyte exports get sluggish, especially in Tree view, which builds DOM nodes for every element. At tens of megabytes, use a streaming command-line tool instead.
No request carries it — parsing, formatting and repair all run in your tab. There is one thing to know before sharing a link: formatting writes the input, the indent setting and the search term into the page URL so a session can be bookmarked or reloaded, which also means the payload lands in your browser history. Clear the input before copying the address if the data contains tokens, keys or customer records.
It validates standard JSON only. JSON5 and JSONC features — comments, trailing commas, unquoted keys, single quotes — are reported as errors, though Repair converts most of them to strict JSON first. NDJSON and JSON Lines files are not a single JSON value at all, so they will not parse; wrap the records in square brackets with commas between them to inspect the whole file as an array.
JSON numbers are parsed into IEEE-754 double-precision floats, which represent integers exactly only up to 9,007,199,254,740,991. A 19-digit database ID or a snowflake ID exceeds that and is rounded to the nearest representable value — silently, with no error. This is a property of JSON in JavaScript rather than of this page. If identifiers must survive a round trip intact, transmit them as strings.
Use Cases
Reading a Minified API Response
Paste the single-line body copied out of a browser network tab or a curl run and get an indented document with a depth and key count, so you can see the response shape before writing the code that consumes it.
Finding the Character That Broke a Deploy
When a config parser fails with an unhelpful message, paste the file here to get the exact position of the first syntax error — usually a trailing comma left behind after deleting the last entry in a list.
Converting a JSONC Config to Strict JSON
Take a settings file written with comments and trailing commas, run Repair to strip them, and produce a file that a strict server-side parser will accept — then check the URLs in it survived the pass.
Mapping an Unfamiliar Payload
Open a vendor webhook body in Tree view, collapse the branches you do not care about, and read the child counts to work out which array holds the records you actually need.
Checking a File Before You Commit It
Drop a hand-edited package.json, tsconfig.json or translation bundle onto the page and confirm it parses, so the build fails on your machine rather than in the pipeline ten minutes later.
Measuring Payload Size Before Optimising
Minify a response and read the byte figure in the stats bar to find out how much of a slow endpoint is actually data, and how much was whitespace that compression would have removed anyway.