Fix Invalid JSON Online Free: Common Errors & Solutions
Got a JSON error? Paste it into our JSON Formatter to find the exact problem. Here are the most common JSON errors and how to fix them.
The 7 Most Common JSON Errors
1. Unexpected Token Error
This is the #1 JSON error developers encounter. It means the parser found a character it did not expect. The most common causes:
- Trailing commas:
{"name": "John", "age": 30,}— the comma after30is invalid in JSON. Remove it. - Single quotes:
{'name': 'John'}— JSON requires double quotes. Change to{"name": "John"}. - Unquoted keys:
{name: "John"}— all keys must be in double quotes. - Comments:
{"name": "John" // user}— JSON does not support comments.
2. Unexpected End of JSON Input
Your JSON is incomplete. Missing a closing } or ]. Count your brackets — every opening bracket needs a matching close.
3. Expected Property Name or '}'
Usually a missing comma between key-value pairs:
// Wrong\n{"name": "John" "age": 30}\n// Correct\n{"name": "John", "age": 30}4. Bad Escape Character
Backslashes in JSON strings must be escaped as \\. File paths like C:\Users\file must be C:\\Users\\file.
5. Duplicate Keys
While technically valid JSON, duplicate keys cause unpredictable behavior. The last value wins in most parsers.
6. Number Format Errors
Leading zeros (09), hex numbers (0xFF), and NaN/Infinity are not valid JSON numbers.
7. BOM (Byte Order Mark)
Some editors add an invisible BOM character at the start of the file. This causes "Unexpected token" at position 0. Remove it with a hex editor or use our JSON Formatter which handles this automatically.
Fix Your JSON Now
Paste broken JSON and get the exact error with line and column numbers. 100% free, runs in your browser.
Open JSON FormatterHow to Prevent JSON Errors
- Use a JSON Schema Validator to validate structure
- Use YAML for config files where you need comments
- Always use
JSON.stringify()to generate JSON, never string concatenation - Set your editor to use double quotes for JSON files
Related: JSON Best Practices, YAML vs JSON, JSON Formatter