Fixing the JSON Error You Cannot Find
By toolbelt maintainers ·
Updated
The parser says line 412 and you swear line 412 looks fine. Here is what actually goes wrong, and how to find it faster.
What is this tool?
Validating JSON means asking one question: does the browser parser accept this text? It says nothing about whether the data makes sense for your application. Those are different jobs, and confusing them wastes time.
How it works
I parse the text with the native JSON parser and catch the exception. The parser reports a character offset, which I convert to a line and column. That conversion matters: most tools report a position, and counting characters by hand is how you lose an afternoon.
Example
This fails:
{
"name": "Ada",
"tags": ["x", "y",],
}
Error: line 3, column 31 — trailing comma.
Delete both trailing commas and it parses.When to use it
Before you send a payload and after you receive a weird one. Also when a config file fails to load at startup, which is when you least want to be debugging by eye.
Optimization Tips
The three things that cause most failures: a trailing comma, a single quote where a double quote belongs, and a comment. None of those are legal in JSON, even though all three work in JavaScript. If you need comments in config, you want JSON5 or YAML, not JSON.
Frequently Asked Questions
Does this check my data types?
Can it fix the error for me?
Why does it report a different line than my editor?
What if the file is huge?
Related tools
- JSON FormatterBeautify, validate, minify, and view JSON. Format messy API responses into readable code or compress it to save bandwidth, running safely in your browser.
- JSON MinifierCompress JSON to a single line. Remove all unnecessary whitespace and line breaks to reduce payload size for production APIs without altering the underlying data.
- JSON ViewerView JSON in an interactive, collapsible tree structure. Easily navigate massive API responses, expand specific nodes, and inspect deeply nested objects or arrays.
- XML FormatterFormat and validate XML documents. Add proper indentation, catch malformed tags, and minify XML markup for optimized data transfer in SOAP APIs or RSS feeds.