Developer Workflow

Format JSON for API debugging

Learn how to format, validate, and inspect API JSON responses so missing commas, wrong nesting, and invalid payloads are easier to find.

Problem

Raw API responses are often compressed into a single line. That makes it difficult to see whether an object is nested correctly, whether an array contains the expected records, or whether a trailing comma broke parsing.

When to use this

  • A REST or GraphQL response is valid but too dense to inspect.
  • A test fixture fails because the JSON payload is malformed.
  • A webhook body needs to be checked before it is pasted into an issue or support ticket.

Steps

  1. Step 1

    Paste the raw response

    Copy only the JSON body from your API client or browser network tab and paste it into the formatter.

  2. Step 2

    Format with indentation

    Apply formatting so nested objects, arrays, and repeated fields are visible at a glance.

  3. Step 3

    Read the validation error

    If parsing fails, use the reported line and column to jump to the broken comma, quote, brace, or bracket.

  4. Step 4

    Minify only after debugging

    Once the structure is correct, minify the payload if it needs to be copied into an environment variable, fixture, or curl command.

Example

API response with nested user data

Input

{"user":{"id":42,"email":"dev@example.com","roles":["admin","billing"]},"meta":{"requestId":"req_9f21","durationMs":128}}

Output

{
  "user": {
    "id": 42,
    "email": "dev@example.com",
    "roles": [
      "admin",
      "billing"
    ]
  },
  "meta": {
    "requestId": "req_9f21",
    "durationMs": 128
  }
}

Common mistakes

Formatting logs that include non-JSON prefixes

Remove timestamps, log levels, and labels before validating. JSON parsers expect the first character to be an object, array, string, number, boolean, or null.

Debugging escaped JSON without decoding it first

If the payload is a JSON string inside another JSON object, decode or unescape that field before treating it as a standalone response.

FAQ

Does formatting JSON change the data?

Formatting should only change whitespace and indentation. The keys, values, arrays, and object nesting should remain the same.

Why does valid JSON from an API still look unreadable?

Many APIs send minified JSON to reduce payload size. It is valid for machines but difficult for humans to inspect until it is formatted.

Should I paste production secrets into a JSON formatter?

Avoid pasting secrets into any tool unless you understand where processing happens. SimpleWebUtils tools are designed for browser-side workflows, but sensitive tokens should still be redacted before sharing or saving.