Skip to tool
ecech.
💻 Developer & Code

JSON Formatter and Validator with Error Line Numbers

Paste broken JSON and get the exact line and column that failed, with a human explanation of what the parser expected. Format, minify, sort keys and copy out.

Advertisement

How the calculation works

What the parser tells you Unexpected token } at position 147 What you actually need line 9, column 14 — trailing comma Offset → line/column 1. Count newlines before the offset → line 2. Offset minus last newline index → column 3. Inspect the token before it → likely cause 4. Print that line with a caret underneath All of it runs locally — nothing is uploaded.

How to Use This Tool

Every JSON parser gives you the same unhelpful answer when a document is malformed: a character offset. Unexpected token } in JSON at position 147 is technically accurate and practically useless, because no editor in the world shows you character 147. This tool converts that offset into a line and column, prints the offending line, and tells you in plain English what the parser was expecting instead.

Validating and formatting

Paste or type your JSON into the editor. Validation runs as you type, so you do not need to press anything to find out whether the document parses. If it does, you get a green confirmation and a set of statistics. If it does not, you get a red panel naming the line, the column, the character found and a short diagnosis — a trailing comma, an unquoted key, a single quote where a double quote belongs, or a value that was never closed.

Format pretty-prints the document with your chosen indentation. Two spaces is the common default; four is conventional in some Python and Java codebases; a real tab is what a few linters insist on. Minify strips every optional byte, which matters when the document is going into a URL, an environment variable or an API payload where size is billed. Sort keys reorders every object recursively into alphabetical order, which is the single most effective trick for making a diff between two API responses readable.

Reading the statistics

Four figures appear once the document is valid. Size is the byte length as UTF-8, not the character count — those differ the moment you have an accent or an emoji in a string. Keys counts every key in every nested object, which is a fast way to sanity-check that a paginated response returned what you expected. Max depth reports how deeply nested the structure is; if that number surprises you, your schema probably needs flattening. Minified saving shows what you would gain by removing whitespace, which is usually 15–30% on a pretty-printed document.

Privacy note that actually matters here

JSON payloads routinely contain access tokens, customer records and internal identifiers. This page never transmits your input. There is no upload, no server round trip and no logging: the parsing happens in your browser using the built-in JSON engine, and closing the tab is all the cleanup required. That is a deliberate design choice, because pasting a production payload into a random online formatter is a surprisingly common way to leak a credential.

Advertisement

Frequently Asked Questions

Why does my JSON fail when it looks fine?
The three most common causes are a trailing comma after the last item in an object or array, keys wrapped in single quotes instead of double quotes, and a stray comment. All three are legal in JavaScript and illegal in JSON. The error panel names which one it found and points at the exact line.
Can it handle JSON5, JSONC or comments?
No, and that is intentional. This validates against the strict JSON specification, which is what an API, a config loader or a database column will enforce. If your file contains comments it is JSONC, and a strict parser will reject it wherever it is deployed, so it is better to see that failure here first.
Is my data uploaded anywhere?
Never. The document is parsed by your browser's own JSON engine and never leaves the page. There is no request to any server, which means you can safely paste payloads containing tokens or customer data without them being logged somewhere you do not control.
What does sorting keys actually help with?
Diffs. Two API responses containing identical data but in a different key order will show as completely different in git or a diff viewer. Sorting both recursively means only genuine value changes remain, which turns a hundred-line diff into the two lines you needed to see.
How large a document can it handle?
Comfortably a few megabytes. Beyond that the browser will still parse it but the editor becomes sluggish because it is a plain textarea rather than a virtualised editor. For very large files a command-line tool like jq is a better fit.
Why is the byte size different from the character count?
JSON is UTF-8 in practice, and UTF-8 uses one byte for ASCII, two or three for most accented and CJK characters, and four for emoji. A 100-character string containing emoji can easily be 200 bytes, which matters when you are near a payload size limit.
Does minifying change my data?
No. Minifying only removes insignificant whitespace between tokens. Every key, value, type and ordering is preserved exactly, and re-formatting the minified output returns you to the same document.

Related tools in Developer & Code

Browse all Developer & Code tools