Structured data guide

How to debug invalid JSON without guessing

A repeatable workflow for API responses, configuration values, webhook bodies, and copied log payloads.

ToolsNHelpers editorial teamReviewed 10 August 20268 minute read

Start with the first parser error

A JSON parser usually reports the earliest point where the document can no longer be interpreted. Later lines may look wrong only because an earlier quote, comma, brace, or bracket changed the structure. Copy the payload into the JSON Formatter, format it once, and investigate the first reported location before editing several places at the same time.

Preserve the original payload in another tab or file. A formatter should help you understand the data, not become an uncontrolled editing step. If the payload came from an HTTP response, record its content type and status code too; an HTML error page returned by a proxy is not malformed JSON—it is the wrong response format.

JSON is narrower than a JavaScript object literal

Valid JSON requires double-quoted property names and string values. It does not allow comments, trailing commas, single-quoted strings, undefined, functions, or special numeric values such as NaN and Infinity. These constructs may work in source code while failing in a strict API or configuration parser.

{
  "release": "2026.08",
  "enabled": true,
  "targets": ["api", "worker"]
}

Notice that the version is quoted. Without quotes, a value such as 01 is invalid JSON, while values that look numeric can also lose meaningful leading zeroes when treated as numbers.

Check structure before meaning

Once the payload parses, use the tree view to confirm that arrays and objects appear where the consumer expects them. Parsing success does not prove that the data matches an API schema. A field can be spelled incorrectly, a number can arrive as a string, or an array can contain objects with inconsistent fields while the overall document remains valid JSON.

Test representative edge cases: an empty array, a null value, an escaped quote, Unicode text, and a nested object. Then validate the corrected payload in the actual receiving application or against its published JSON Schema.

A practical checklist

  1. Keep an unchanged copy of the failing payload.
  2. Confirm that the response is intended to be JSON.
  3. Fix only the first syntax error and parse again.
  4. Review types and nesting after syntax is valid.
  5. Test the result in the target system.

References

This guide uses the grammar defined by ECMA-404 and the interoperability guidance in RFC 8259.

An unhandled error has occurred. Reload x