You're staring at a 400 error. The API call looks right. The endpoint is correct. The headers are fine. Then you paste the request body into a formatter and see it immediately: a trailing comma after the last item in an array.
One character. Thirty minutes.
What Makes JSON Valid?
JSON has a small number of rules, but they're strict. The parser doesn't guess at intent — it either parses or it fails.
The three mistakes that cause most JSON errors:
Trailing commas — JSON does not allow a comma after the last element in an object or array. JavaScript does (since ES5). This difference trips up developers constantly when moving data between environments.
// Invalid
{
"name": "Alice",
"role": "admin",
}
// Valid
{
"name": "Alice",
"role": "admin"
}
Unquoted keys — JavaScript object literals allow unquoted keys ({ name: "Alice" }). JSON does not. Every key must be a double-quoted string.
Single quotes — JSON requires double quotes for both keys and string values. Single quotes are valid JavaScript but will fail JSON parsing every time.
// Invalid
{ 'name': 'Alice' }
// Valid
{ "name": "Alice" }
Formatted vs. Minified — When to Use Each
Both are valid JSON. The difference is whitespace.
Formatted JSON (also called pretty-printed) uses indentation and line breaks to make the structure readable. Use this during development, debugging, and code review. When a human needs to read it, format it.
Minified JSON strips all unnecessary whitespace to reduce file size and transmission time. Use this in production payloads, API responses, and anywhere bytes matter. A large formatted JSON file can be 20–30% larger than its minified equivalent.
The workflow: write and debug with formatted JSON, minify for production.
How to Format It in Seconds
The JSON Formatter on this site does three things: formats, validates, and minifies. Paste in any JSON — even broken JSON — and it immediately tells you whether it's valid and shows the first error if it isn't.
The validator is the most useful part for debugging. Instead of reading through a wall of minified JSON to find the problem, paste it in, click Format, and the error message tells you exactly which line and character failed.
For key naming conventions in your JSON — camelCase vs. snake_case vs. kebab-case — the Case Converter can help if you're normalizing key names across different data sources.
Five JSON Hygiene Rules
Keep these in mind when writing or reviewing JSON by hand:
- No trailing commas. Every item except the last one gets a comma.
- Double quotes only. On keys and string values, always.
null, notNULLorNull. JSON is case-sensitive. So aretrueandfalse.- Numbers don't need quotes.
"age": 30is correct."age": "30"stores a string. - Validate before you ship. One pass through a formatter catches errors a code review misses.
A Note on Sensitive Data in JSON
When pasting JSON into any online tool — including formatters — check that it doesn't contain API keys, tokens, or passwords. The Password Generator on this site generates cryptographically random secrets entirely in the browser, with nothing sent to a server. The same privacy-first approach applies to the JSON Formatter: your data never leaves your machine.
When JSON Isn't the Right Tool
JSON is the right default for most data interchange. But it has limits:
- Comments aren't supported. If you need annotated configuration, JSONC (JSON with Comments) or YAML may be better choices.
- Large numbers lose precision. JSON numbers are IEEE 754 floats, which can't represent integers larger than 2^53 exactly. For large IDs or financial data, use strings.
- No schema enforcement. JSON itself doesn't validate types or required fields. For that, look at JSON Schema or a typed serialization format like Protocol Buffers.
For the vast majority of API work and configuration files, standard JSON is exactly right.
Quick Checklist
- [ ] All keys are double-quoted strings
- [ ] No trailing commas after the last item in any object or array
- [ ] All string values use double quotes (not single)
- [ ]
true,false, andnullare lowercase - [ ] Ran the JSON through a validator before using it in production
- [ ] Minified the payload if it's being sent over a network