How to Read and Format Messy JSON (Without Freezing Your Browser)

· Javed Iqbal · 6 min read

An API hands you back one long, minified line of JSON. No line breaks, no indentation, maybe 40KB of it, and somewhere in there is the one field you need. Reading that by hand is not happening.

This is the boring task I do more than almost anything else, so here is how to do it quickly: format it so it is readable, pinpoint the exact character where invalid JSON breaks, and deal with the genuinely big responses that lock up a browser tab.

Make it readable in two seconds

Paste the blob into the JSON viewer and it formats and indents instantly, with a collapsible tree so you can fold away the parts you do not care about. Take a response like this:

{"user":{"id":42,"name":"Ada","roles":["admin","editor"],"meta":{"active":true,"last_seen":null}}}

and it becomes something you can actually scan:

{
  "user": {
    "id": 42,
    "name": "Ada",
    "roles": ["admin", "editor"],
    "meta": {
      "active": true,
      "last_seen": null
    }
  }
}

Collapse user.meta, find roles, copy the path. Done. On a deeply nested response the tree view is the difference between five seconds and five minutes.

Finding why your JSON is invalid

Most "why won't this parse" bugs are one of four things, and they are always in the same spots:

  • A trailing comma after the last item. Valid in JavaScript, illegal in JSON.
  • Single quotes instead of double. JSON only accepts double quotes.
  • Unquoted keys ({name: "Ada"}). Keys must be quoted strings.
  • A stray comma, or a missing one, between objects in an array.

The viewer flags the line where parsing fails, which is usually one or two lines past the real mistake, so look just above the highlighted spot. And if what you actually have is a JavaScript object, not JSON (unquoted keys, single quotes), run it through the JS to JSON converter instead, which fixes those for you rather than just complaining about them.

The big-file problem nobody warns you about

This one bit me: I pasted a multi-megabyte API dump into a browser JSON tool and the whole tab froze for ten seconds. The reason is that fully expanding a giant tree means rendering tens of thousands of DOM nodes at once. It is not the formatting that is slow, it is drawing all of it.

Two practical workarounds. Keep most of the tree collapsed and only open the branch you need, so the browser is not drawing everything. And for truly large payloads, view the raw formatted text and use search rather than expanding the full tree. Be honest with yourself about size, too: an in-browser tool is perfect up to a few megabytes, and past that you are better off with a command-line tool like jq that does not have to paint a UI.

Where most of this JSON comes from

For me, nearly always an API. The fast loop is to fire the request in the API tester, which already pretty-prints the response, then drop anything gnarly into the JSON viewer for the tree view and path-copying. Same browser, no files, nothing uploaded. That last part matters when the JSON has tokens or customer data in it, which it often does.

FAQ

How do I format minified JSON?

Paste it into the JSON viewer. It indents and structures it instantly, with a collapsible tree to navigate.

How do I find the error in invalid JSON?

The viewer points to the line where parsing fails. Check just above it for the usual suspects: a trailing comma, single quotes, or an unquoted key.

Can it handle a large JSON file?

Up to a few megabytes comfortably. Keep branches collapsed for big payloads. Past that, a CLI tool like jq is faster because it does not render a UI.

Is my data safe?

Yes. The JSON is processed in your browser and never uploaded, so tokens and personal data stay on your device.

Paste your JSON into the free online JSON viewer and formatter, or pair it with the API tester for the full request-to-readable loop.