JSON Formatter for Developers: Debug API Responses Fast
Table of contents
API responses arrive as one line. Logs wrap them. Support tickets paste them with smart quotes. Your job is to see the shape, confirm it is legal JSON, and find whether the 400 is your payload or theirs. That is a different task from "what is JSON". This guide is the debugging loop.
The JSON Formatter pretty-prints, validates and minifies locally. Access tokens in a body should never go to a random beautifier with a server behind it.
A fast debug loop
- Copy the raw body from DevTools, a gateway log or a failing unit test fixture.
- Paste into the formatter. If it is invalid, read the error position, then look at the line above it. Trailing commas and smart quotes from Slack live there.
- Collapse the tree to the object you care about:
data.items[3],error.details, the nesteduser. - If you need to ship the same data, minify before putting it back in a fixture or header playground. Whitespace is not the bug, but it is noise in a diff.
What usually breaks "valid-looking" JSON
- Trailing commas after the last property. Legal in JS objects, illegal in JSON.
- Single quotes. JSON keys and strings are double quotes only.
- Comments someone left in a "JSON" config. Use JSONC in the editor, not in the wire format.
undefined,NaNorInfinitydumped from JavaScript. They are not JSON values.- A UTF-8 BOM or a
callback(wrapper from JSONP.
Related checks on this site
- JSON Compare when two payloads should match and do not.
- JWT Decoder when the body is fine and the Authorization header is not.
- Diff Checker for two pretty-printed copies.
For a slower primer on the format itself, see how to format, validate and minify JSON.
Frequently asked questions
Why is the API JSON invalid in the formatter but "works" in JavaScript?
You are probably looking at a JS object literal, not JSON. Unquoted keys and trailing commas will parse in JS and fail here, correctly.
Is the payload uploaded?
No. Parsing runs in your browser.
Should I minify before sending to production?
Only if size matters on that channel. Invalid JSON will still be invalid when minified. Validate first.
Open the JSON Formatter and paste the failing body. Free, no signup.