Skip to main content
All articles

Developer

How to Read and Fix Unreadable JSON From an API

Minified API responses are one long line until you adopt the three-habit routine: format first, validate second, diff after a change.

4 min readMay 18, 2026GainUtility

The same payload, twice

Before — minified

{"name":"gau","active":true,"items":[{"id":1,"qty":2}],"ok":true}

After — formatted

{
  "name": "gau",
  "active": true,
  "items": [
    {
      "id": 1,
      "qty": 2
    }
  ],
  "ok": true
}

Open a raw API response and you'll often see one long line of JSON with no spaces. It's technically correct and completely unreadable — and the fix is a habit, not a skill.

Why it looks like that

APIs usually return minified JSON to save bandwidth. Whitespace and line breaks are stripped because they add bytes. Great for the server, terrible for the person trying to read it.

Format first

Before you try to parse a response in your head, format it. A formatter rebuilds the indentation and line breaks, turning one dense line into a structure you can scan. One line becomes a small tree:

Validate before you trust

If something isn't parsing, check whether the JSON is even valid before hunting for logic bugs. A trailing comma or an unescaped quote breaks an entire object — faster to confirm that than to debug a phantom.

Diff after you change things

When you're checking whether a fix worked, a side-by-side diff beats eyeballing two long strings. See exactly which keys moved — and which you didn't mean to touch.