The quick answer

Paste JSON into the left panel. If it is valid, the badge reads Valid and the formatted result appears on the right, ready to copy or download as a file — with your choice of 2-space, 4-space, 1-space or Minified indentation. If it is broken, the badge flips to Invalid and a red box pinpoints the parse error's character position with the surrounding text, so you can see the exact quote, comma or brace that failed. Both sides run entirely in your browser: API payloads, config files and fixture data never leave the page.

How to use the formatter and validator

  1. Paste your JSON

    The left textarea takes any size — a one-line webhook body or a multi-megabyte API dump. The Valid / Invalid badge updates as you paste and as you type.

  2. Choose the indent

    The Indent selector sits under the input: 2 spaces (the de facto standard), 4 spaces, 1 space, or Minified — which strips every byte of whitespace for transport and storage. Switching re-renders the output instantly.

  3. Read the validation verdict

    Valid input shows a green badge and a note stating the indent applied. Invalid input shows a red badge plus the error box: the character position where parsing failed and about 80 characters of context — the offending syntax is in that window.

  4. Copy or download

    Copy puts the formatted JSON on your clipboard; Download saves it as formatted.json. Fix broken input on the left and the output regenerates as soon as it parses.

The eight errors that break real JSON

JSON's grammar fits on one page (RFC 8259), which is why its errors are so repetitive. Eight kinds cover nearly everything the error box ever shows:

ErrorWhat you pastedThe fix
Single quotes{'name': 'Ada'}JSON strings use double quotes only: {"name": "Ada"}
Trailing comma[1, 2, 3,]Remove the comma before the closing bracket
Unquoted key{name: "Ada"}Keys must be strings: {"name": "Ada"}
Comments{ /* note */ }JSON has no comments — use a "_comment" key or JSONC tooling
Smart quotes“Ada”Word processors curl quotes; retype them straight
Single unquoted stringhelloA bare word is not a value — "hello" is
Missing closing brace{"a": [1, 2}Count openers vs closers; the error lands at end-of-input
NaN or Infinity{"n": NaN}JSON numbers are finite decimals — null or a string instead
The error box's character position tells you which row of this table you are looking at.

Two of these deserve their own warning. Single quotes are the number-one error because JavaScript objects allow them and JSON does not — developers paste from source code, not from a file. Smart quotes are the number-one error for non-developers, because a word processor's autocorrect quietly replaces straight quotes with curly ones, and every curly quote is a syntax error in JSON.

What the formatter does and does not change

The formatter re-indents and re-spaces; it does not rewrite your data. Key order stays exactly as pasted, string contents are untouched, and numbers round-trip through JavaScript's number type — integers stay integers, and decimals that are exactly representable print back exactly. One honest limitation comes with that number handling: integers beyond 2^53 − 1 (9,007,199,254,740,991) exceed JavaScript's safe integer range and lose precision on the round trip. Snowflake IDs and 64-bit database keys are the classic victims; if you are formatting those, use a tool that parses with BigInt. Everything else about your document — nesting, order, unicode escapes — comes through unchanged.

Minified: when and why

Minified mode strips every space, newline and indent that the grammar allows. The result is not just smaller on screen: for a file served over a network, minification is the whole point. A pretty-printed 2-space build of a large config can be 30-50% larger than its minified form — meaningless for a 200-line fixture, meaningful for a payload served a million times. The work pattern the selector supports: format to 2 spaces while you are reading and debugging, flip to Minified when the JSON goes into production, and copy once more.

One object, three widths

Input

{"user":{"name":"Ada","roles":["admin","dev"]}}

Output

2-space: the same object across four readable lines, one nesting level per line. 1-space: identical structure at half the width — for deeply nested documents that still must fit a review window. Minified: the input itself, stripped to its 47 essential characters.

The JSON grammar in one minute

The whole language has seven value types and one string rule, which is why the validator can be exact:

ValueLegal syntaxCommon illegal variant
Object{ "key": value, ... }Unquoted keys, single quotes, trailing commas
Array[ value, value, ... ]Trailing comma after the last element
String"..." with \" \\ \/ \b \f \n \r \t \uXXXX escapesSmart quotes, unescaped newline inside a string
Numberinteger, decimal, exponent — finite onlyNaN, Infinity, leading plus, leading zeros (01)
true / falselowercase exactlyTrue, TRUE, False
nulllowercase exactlyNULL, Null, undefined
WhitespaceBetween any two tokens, anywhereInside strings it is data, not syntax
RFC 8259 is 16 pages long; this table is the part that rejects your file.

A debugging session, worked

The most common session this page serves: a payload copied out of a log file or a ticket, pasted in, and broken twice. Watch both errors surface exactly as the tool reports them:

First paste — the log's smart quote

Input

{"customer": "Jose’s Order”, "total": 41.50, }

Output

Invalid. The error box points near the curly apostrophe in Jose’s — a word processor or chat client replaced the straight quote mid-string. Retype it: "Jose's Order".
Second paste — the trailing comma

Input

{"customer": "Jose's Order", "total": 41.50, }

Output

Still Invalid — the parse now reaches the comma before the closing brace. Delete the trailing comma after 41.50; the next paste renders 2-space formatted, Valid badge green, ready to copy.

Two errors in one eleven-word object is not unusual — copied JSON accumulates damage in proportion to how many hands it passed through. The character-position error box exists precisely because "unexpected token" at line 1 of a single-line payload tells you nothing, while "near character 18" with context tells you everything.

Why so strict? JSON, JSONC and JSON5

Every error in the table above is legal in some other format — which is the exact reason people hit them. Comments and trailing commas are allowed in JSONC (what VS Code uses for settings.json and tsconfig.json); single quotes, unquoted keys, multi-line strings and even comments are allowed in JSON5; unquoted keys are legal in YAML and in JavaScript object literals. Pasting from any of those worlds into strict JSON produces the errors this validator reports. The strictness is deliberate: JSON's value is that every parser in every language agrees on the same grammar, and every one of those conveniences would break that agreement. So the fix is always to conform, not to loosen — convert your JSONC to JSON before shipping it to a consumer that expects the standard.

Validating before it costs you

The failure modes of unvalidated JSON are all downstream, which is why a paste-in validator earns its keep: a config file that breaks at deploy because of one trailing comma; a JSON column in a database that rejects the row; a webhook payload that the receiver silently drops; a CI fixture that fails the whole suite on a smart quote. None of them announce themselves at the keyboard — they explode later, somewhere expensive. The ten-second ritual is the same every time: paste, glance at the badge, fix what the red box shows, move on.

The badge also guards a subtler case: JSON that is valid JavaScript but not valid JSON — unquoted keys, single quotes, trailing commas are all legal in a .js file and illegal in a .json file. Pasting is how that difference surfaces before a parser that is far less polite about it does.

JSON Formatter & Validator vs the alternatives

ToolFormatsValidates with error positionMinifyWhere the JSON goes
Toolzep JSON Formatter & Validator2/4/1-space, minifiedYes — character position + contextYesStays in your browser
JSONFormatter.org2/4-space, minifyYesYesServer-side processing
JSONLint.com2/4-spaceYesPro featureServer-side
JSONEditorOnline.orgTree + code editingYesYesServer-side with account features
jq (command line)Any indent via flagsParse errorsYesLocal
Feature claims for third-party sites are category-level; verify a site's current behavior before relying on it.

The honest differentiator is the last column. JSON pasted into a formatter is often the least sanitized data a team handles — real API responses, production config, export files with user records. A client-side formatter cannot log what it never receives. The offline test makes it verifiable: load the page, disconnect, keep working.

Frequently asked questions

How do I format JSON?

Paste it into the input box and pick an indent — 2 spaces, 4 spaces, 1 space or Minified. The output panel renders the formatted JSON instantly, with Copy and Download buttons beside it.

How does the validator find my JSON error?

The instant parsing fails, the input panel flags Invalid and a red box reports the parse error near its exact character position, showing roughly 80 characters of context around the offending spot. Almost every real-world JSON error is one of eight kinds, and the context window makes which one obvious.

Why does my JSON fail validation when it looks fine?

The most common cause is single quotes — JSON requires double quotes for all strings and key names. The runners-up: trailing commas, unquoted keys, comments (JSON has none), and smart quotes pasted from a word processor.

What is the difference between formatting and validating?

Validation answers "is this syntactically legal JSON?" Formatting answers "is this readable?". The tool does both at once: if the input parses, it prints reformatted output; if it does not, it shows you where parsing stopped.

Is my JSON uploaded anywhere?

No. Parsing and formatting run in JavaScript in your browser — nothing is transmitted, logged or stored. This matters for JSON specifically: API responses, config files and fixture data often contain real user records and credentials that should not make a round trip through a server.

Which indent should I use?

2 spaces is the de facto standard — it is what Prettier, most style guides and most codebases use. 4 spaces matches Python-adjacent teams; 1 space saves width; Minified collapses everything for transport and storage.

What is the maximum JSON size this handles?

There is no server-side limit because nothing is uploaded — the practical limit is your browser's memory. Multi-megabyte API dumps format fine; very large files simply take a moment.

Does the tool preserve my key order?

Yes. Key order in objects is preserved as you pasted it — the formatter re-indents, it does not re-sort. If you want keys sorted alphabetically, that is a separate tool that sorts recursively.

Why did my numbers change format?

They round-trip through JavaScript's number type: integers stay integers, and decimals that can be represented exactly print back exactly. Very large integers beyond Number's safe range (2^53 − 1) lose precision on round-trip — a JavaScript engine limitation, not a choice.

Can it fix my JSON for me?

It validates and formats, and the error locator tells you exactly what to fix — but it will not silently repair broken syntax, because a formatter that guesses can silently change data. The eight-error table in this article is the fix list.

Sources and further reading

Sources and further reading

We cite primary sources (standards bodies, government agencies, official documentation) wherever they exist so you can verify every number on this page yourself.