Developer
JSON Formatter
Format, validate and beautify JSON in the browser with inline error locations — what you paste is parsed on your own device rather than sent to a server.
JSON formatter
Nothing pasted yet — paste or type JSON above to format, minify or validate it.
JSON pretty print
JSON minifier
Strip every insignificant space, tab and newline — useful before pasting JSON somewhere size counts, like a URL query param or a small config file.
JSON validator
Paste JSON above to see whether it’s valid, and exactly where it breaks if not.
Paste or type JSON into the box above and use it three ways: Format rewrites it in place at your chosen indent (2 spaces, 4 spaces, or a tab), Minify strips it down to the smallest valid representation, and the validator below the box tells you immediately whether what you pasted is valid — and if it isn't, exactly where it breaks and why. Nothing you paste here is sent anywhere; see "Is it safe to paste my API response into this JSON formatter?" below for exactly what that promise covers.
JSON validator: how to read a red error
Half of what brings someone to a JSON tool is not "make this pretty," it's
"why won't this parse" — and a bare error from most parsers, JavaScript's
JSON.parse included, says little more than "unexpected token" at a raw
character offset nobody can picture. The validator here is a purpose-built
scanner rather than a wrapper around that message: it reports the line and
column of the exact fault, shows the offending line with a caret pointing at
the specific character, and — for the handful of mistakes that account for
most invalid JSON in practice — names what actually went wrong: a trailing
comma, a single-quoted string, an unquoted object key, a curly/smart quote,
or a value like NaN, undefined, Python's None, or True/False where
JSON needs null, true or false. Click "Jump to error" and the exact
faulty span is selected in the box above, using your browser's own text
selection rather than a separate overlay, so you can see precisely what the
diagnosis is pointing at inside your own document.
One more thing the validator checks that a plain parser does not: a duplicate key. Valid JSON can legally repeat a key inside the same object, and every mainstream parser keeps only the last value and silently drops the earlier one — which means a duplicate key is not a parse error at all, it is a working document quietly losing data. When this tool finds one, it reports "valid JSON" (because it is) alongside a warning naming the repeated key and the line the first occurrence was on, so a real mistake does not read as a clean pass.
JSON pretty print: choosing 2, 4 or tab indentation
Pretty-printing (also called "beautifying") takes JSON that has been minified, logged on one line, or hand-edited into an inconsistent mess, and re-lays it out with one value per line and consistent indentation. The indent choice is a style preference rather than a correctness one — 2 spaces is the most common default across formatters and style guides, 4 spaces reads more spaciously on a wide monitor, and a tab lets each person's editor render the same file at whatever width they've configured. Whichever you choose, the underlying data is identical; only the whitespace around it changes, which is also why re-formatting the same valid JSON at a different indent is always safe to do more than once.
JSON minifier: strip it for production
Minifying removes every space, tab and line break that JSON allows but does not require — the exact inverse of pretty-printing, and useful whenever the JSON is headed somewhere size or line-count matters: embedded in a URL query parameter, written into an environment variable, or shipped as part of a production payload where a few hundred bytes of formatting whitespace add up across many requests. Minifying never changes what the data means, only how much space it takes to say it, and — like formatting — it only runs once the validator confirms the input actually parses; there is nothing to consistently strip from JSON that is not valid to begin with.
Large or unusual input
A tool that parses on every keystroke can start to lag once the input runs into the megabytes, so above roughly 200,000 characters this tool waits briefly after you stop typing before re-checking, and above 5,000,000 characters (on the order of 5MB) it stops checking automatically altogether — a "Check now" button runs it once, on demand, so a very large paste never makes the page stutter without warning. Below either threshold, checking is instant and happens as you type. The optional tree view under the validator lets you collapse and expand each object or array in a successfully parsed document; it is capped at a few thousand nodes for the same reason, so an enormous payload falls back to the formatted text rather than trying to draw tens of thousands of expandable rows at once.
Questions
- Why is my JSON invalid?
- The most common reasons, in order of how often they show up here: a trailing comma left after the last item in an object or array (JSON does not allow one, unlike a JavaScript object literal); a single-quoted string instead of a double-quoted one; an object key typed without quotes at all; a curly or 'smart' quote pasted in from a word processor, notes app or chat client instead of a plain straight quote; and a value like Python's None, True or NaN where JSON needs null, true or a real number. Paste the text into the box above and the validator names which of these it is, along with the exact line and column, rather than leaving you to scan the whole document by eye.
- What is a trailing comma JSON error, and why doesn't JSON allow it?
- A trailing comma is a comma left after the last item in an object or array, right before the closing brace or bracket — for example `{"a": 1, "b": 2,}`, with a comma after `2`. Many languages, including JavaScript object and array literals, accept this without complaint, which is exactly why it is such a common mistake: someone edits a JSON file by hand, deletes the last item, and leaves the comma that used to separate it from the one before. The JSON specification (RFC 8259) simply does not include a trailing comma in its grammar, so every strict JSON parser rejects it outright rather than tolerating it the way a JavaScript engine does. This tool points at the exact comma and names it "Trailing comma" rather than a generic parse error, so the fix is "delete this one character" instead of a search.
- Can I use single quotes in JSON?
- No — the JSON specification requires double quotes (") for every string and every object key, and a single-quoted string ('like this') is not valid JSON even though it is completely normal in JavaScript, Python and several other languages. This is one of the most common reasons JavaScript-flavoured data fails to validate as JSON: copying an object literal out of source code and pasting it here as-is. The validator above catches this specifically — it reports 'Single-quoted string' rather than a generic syntax error, and names the exact text that needs to change from single to double quotes.
- Why does my pasted JSON show a smart quote or curly quote error?
- Word processors, many notes apps and some chat clients automatically convert a plain straight quote (") into a curly, typographic one (“ or ” for double quotes, ‘ or ’ for single quotes) as you type, because that conversion looks better in ordinary prose. JSON has no idea what a curly quote is — it only recognises the plain straight double quote — so text copied out of one of those tools often carries invisible curly quotes that break every string and key they touch. This tool detects the specific curly-quote characters and calls it out by name, because a curly quote is easy to miss by eye (the two look almost identical at normal reading size) but the fix, once you know it is there, is a one-character replacement.
- Is it safe to paste my API response into this JSON formatter?
- Yes, in the sense that matters: everything on this page — parsing, formatting, minifying and validating — runs entirely inside your own browser using ordinary JavaScript, and nothing you paste is sent to a server, logged, or stored anywhere, including on this device. That matters here specifically because a JSON formatter is exactly the kind of tool people paste a live API response, a webhook payload or a chunk of a config file into, and that text can easily contain an access token, a session identifier or a customer's data. This page also never writes what you paste to localStorage or to an account, on purpose — closing or reloading the tab clears it completely, so nothing you check here is still sitting around on a later visit, on this machine or anyone else's.
- What does a duplicate key in JSON actually do?
- A JSON object with the same key written twice, like `{"id": 1, "id": 2}`, is technically valid JSON — the specification does not forbid it — but every parser has to pick one value to keep, and the near-universal behaviour (matching this tool and matching `JSON.parse` in every major browser) is that the LAST occurrence wins and every earlier one is silently discarded. That makes a duplicate key a real, working piece of data that is quietly losing information rather than a syntax error: nothing crashes, nothing warns by default, and the earlier value is simply gone. This tool parses a duplicate key successfully (it is valid JSON, so this is correct) but flags it as a warning naming both the key and where the first occurrence was, specifically so a genuine mistake does not slip through looking like success.