JSON Formatter
Beautify, minify, sort keys, and validate. Zero server.
Blog

Find the Error in Broken JSON, Then Format It

Which line is your JSON parse error on? How to validate, sort keys, and minify JSON safely, all inside your browser.

A developer-style cover on an indigo background with the large words 'Format JSON' beside cards for sort keys, minify, validate, and error location.

You paste an API response and one red line answers back: Unexpected token. You scan for the problem, then end up counting brackets one by one. JSON has simple rules, and that simplicity is exactly why one small slip stops the whole parse. Here is how to find the break first.

Broken JSON: locate the problem before you fix it

A JSON parser stops at the first error and tells you where it is. The message is easy to skim past, but the line and column are sitting right inside it.

Leave a comma after the last value, as in { "name": "PiPi", "role": "editor", }, and the parser answers Expected double-quoted property name in JSON at position 40 (line 4 column 1). The PiPi Worlds JSON formatter points straight at that line and column, so you jump to line 4, where the closing brace sits. The culprit is the trailing comma just before it.

The usual suspects are a short list.

ErrorSymptom
Trailing commaAn extra comma after the last item
Missing quotesA key or string not wrapped in double quotes
Unbalanced bracketsA { or [ left unclosed
Missing colonNo : between key and value

JSON does not allow single quotes, comments, or trailing commas (RFC 8259). Most of these mistakes come from treating it like a JavaScript object literal.

Beautify it, or minify it down to one line

When the JSON is valid, indentation makes the structure readable at a glance. Pick two spaces, four spaces, or a tab to match your team’s convention.

When you need to shrink the payload instead, minifying strips every space. { "a": 1, "b": [1, 2, 3] } collapses to {"a":1,"b":[1,2,3]}. Moving the same data between a readable form and a compact one is a common enough chore that the two buttons earn their place.

Sort keys to diff two API responses

Less known, but genuinely useful for debugging, is sorting keys. It reorders every object’s keys alphabetically.

You have probably seen two servers return the same data, only for the diff to light up red because the key order differs. Run both through sort-keys and the ordering noise vanishes, leaving only the values that truly differ. For instance, {"name":"PiPi","id":42,"active":true} becomes ordered as active, id, name, lining up cleanly against the other response.

The trap where big numbers change silently

This one costs real time if you do not know it. JSON numbers parse as IEEE-754 doubles in JavaScript.

The problem appears once a value passes the safe integer range. Format {"id": 12345678901234567890} and you get back {"id": 12345678901234567000}. The trailing digits quietly became 000. JavaScript only handles integers exactly up to 2^53, which is 9007199254740991. Large IDs, like Discord or Twitter snowflakes, sail past that easily. If the exact digits matter, keep the value as a string ("12345678901234567890") in the source JSON. Run your data through the tool once and you can see immediately whether this trap is hiding in it.

Where are you pasting that API response?

One last point worth making. The JSON you paste in to debug often carries access tokens, internal IDs, or personal data. Any online formatter that ships your input to its server hands that sensitive payload straight to a third party.

The PiPi Worlds JSON formatter runs every parse inside your browser. Your input is never transmitted, so config files and API responses full of tokens are safe to clean up. If a base64 value inside the JSON catches your eye, the Base64 tool is one click away, and if that value turns out to be a JWT, the JWT decoder takes it from there.

Frequently asked questions

How do I tell which line my JSON parse error is on?
The parser reports the position of the first error as a line and column, for example 'Expected double-quoted property name in JSON at position 40 (line 4 column 1)'. The cause is usually just before it, a trailing comma or a missing closing bracket.
What are the most common JSON syntax errors?
A trailing comma after the last item, keys or strings not wrapped in double quotes, unbalanced brackets, and a missing colon between key and value. JSON does not allow single quotes, comments, or trailing commas (RFC 8259).
When is sorting keys useful?
Reordering object keys alphabetically makes it easy to diff two API responses that return keys in a different order. Differences that were only about ordering disappear, leaving only the values that actually differ.
A large number changed after formatting. Is that a bug?
It is not a bug, but a consequence of how JavaScript handles numbers. JSON numbers parse as IEEE-754 doubles, so integers beyond 2^53 (9007199254740991) lose their trailing digits. For large IDs like Discord or Twitter snowflakes, keep the value as a string in the source.
Is the JSON I paste sent to a server?
No. The PiPi Worlds JSON formatter runs all parsing locally with the browser's native JSON engine, and your input is never uploaded, logged, or stored. Config files and API payloads that contain tokens stay private.

Sources

Written by the PiFl Labs content team from public sources and reviewed in-house before publishing.

Last reviewed:

Back to the tool →