Common JSON errors
JSON is stricter than JavaScript, so text that looks right often is not:
- Trailing commas after the last item in an object or array are not allowed.
- Single quotes are not allowed; strings and keys need double quotes.
- Unquoted keys (
{name: 1}) are JavaScript, not JSON. - Comments (
//or/* */) are not part of JSON. - Special values like
undefined,NaNandInfinityare not valid; usenullor a string. - Control characters inside strings (a raw newline or tab) must be escaped as
\nor\t.
The validator shows the parser’s message with the line and column, which is usually one character after the real mistake.
Formatting for logs and APIs
Pretty-printed JSON is for people; minified JSON is for machines. Log in one line per event (minified, or structured logging with a JSON formatter) so tools can parse it, and pretty-print only when reading. API responses should be minified and compressed: whitespace adds bytes with no value to clients.
Validating API responses automatically
When an API returns broken JSON, every client fails. An API monitor can request an endpoint every minute, check that the body parses and that fields have the expected values, and alert before users notice. Check what an endpoint returns right now with the HTTP headers checker.
Using it safely at work
Online developer tools are a common way secrets leak: people paste production tokens, customer records or private keys into a website that quietly logs them. This page does all its work in your browser with standard Web APIs, makes no network request with your input, and stores nothing, so it is safe to use with real data, and you can confirm that in your browser’s network panel. Even so, treat anything you paste as you would treat a screenshot: rotate a token that was exposed, never share links that contain it, and prefer command-line tools on the server itself for very sensitive material.