JSON looks simple until a missing comma breaks an entire config file or API response. Here's how to read the errors, and the mistakes that cause them most often.
What "valid JSON" actually means
JSON has a small, strict set of rules: keys and string values must use double quotes (never single quotes), objects and arrays can't have a trailing comma after the last item, and every opening brace or bracket needs a matching close. Break any one of these and the whole file fails to parse, there's no partial credit.
The most common mistakes
- Trailing commas, {"a": 1, "b": 2,} is invalid; that last comma has to go.
- Single quotes, {'a': 1} is invalid JSON, even though it's valid in JavaScript. Always double quotes.
- Unquoted keys, {a: 1} needs to be {"a": 1}.
- Missing a closing brace or bracket, especially common in deeply nested objects where it's easy to lose track.
Reading a parser's error message
Error messages like "Unexpected token at position 47" point to roughly where the parser gave up, but that's often the character right after the actual mistake, not the mistake itself. If the reported position doesn't obviously show a problem, check a few characters before it, especially for a missing comma or quote.
Format and validate your JSON
Use the free JSON Formatter →, paste your JSON to instantly validate it, pretty-print it for readability, or minify it for production, with the exact line and column of any error.Formatting vs. minifying
"Pretty" formatted JSON (with indentation and line breaks) is easier for humans to read and debug. Minified JSON strips all unnecessary whitespace, producing a smaller file, the version you'd actually want in a production API response or a config file being loaded by an app, where every byte and parse cycle counts.
Working with encoded data alongside JSON? The Base64 tool and URL Encoder handle the other two encodings you'll run into constantly when working with APIs.