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.
| Error | Symptom |
|---|---|
| Trailing comma | An extra comma after the last item |
| Missing quotes | A key or string not wrapped in double quotes |
| Unbalanced brackets | A { or [ left unclosed |
| Missing colon | No : 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.