Every JSON validator delivers its bad news in the same terse style: a short message such as unexpected character or missing comma, and little else. Read literally, those phrases sound vague. Read properly, each one describes exactly what the parser was doing at the moment it gave up, and that tells you where to look.
This guide translates the two messages you will meet most often, explains why you only ever see the first error in a file, and shows the reading habit that makes validation fast, using the free JSON Formatter and Validator on Ovatly.
Contents
- Quick answer
- The two messages you will meet most often
- Why you only ever see the first error
- How to read an error message, step by step
- Worked example: one object, broken two ways
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
A JSON validation error message reports the first place the text stopped following the grammar. Unexpected character means the parser met a symbol that is not allowed at that spot, and the real mistake is often the character just before it. Missing comma means two items ran together with no separator between them. Paste your JSON into the JSON Formatter and Validator, choose Validate only so the text is checked without being changed, fix the one thing the message describes, and validate again: a file with three mistakes needs three rounds, because the parser stops at the first error every time.
The two messages you will meet most often
Unexpected character. The parser was reading along, expecting one of a small set of things, and met a character that fits none of them: a closing brace where a key should be, a letter where a comma belongs, a stray symbol inside a number. The important subtlety is that the named character is where reading failed, not necessarily where you went wrong. A trailing comma is the classic case: the comma itself is legal, but it promises another key, and when the brace arrives instead, the brace is the character that gets reported.
Missing comma. Two items sit side by side with nothing between them: two key and value pairs in an object, or two values in an array. The parser finished one item, expected a comma, and found the start of the next item instead. Unlike the first message, this one points close to the fault: the gap between the two items is exactly where the comma has to go.
Everything else is a variation on these two themes. An unescaped quote inside a string surfaces as an unexpected character a few words later. An unquoted key or a single-quoted string fails the same way, because neither fits the grammar at the spot where it appears.
Why you only ever see the first error
A parser cannot skip a broken section and keep reading, because it cannot know where the broken section was meant to end. Once the text stops making sense, every later character is ambiguous: is that quote opening a string, or closing one that started earlier by accident? Rather than guess, the parser stops and reports the first failure.
That makes validation a loop rather than a verdict. Fix the reported problem, validate again, and the next problem, if there is one, gets its turn. A file with three mistakes produces three messages, one per round, and that is normal rather than a sign your fixes are failing. It also means a clean result is meaningful: the whole file was read, start to finish, without a single stop.
How to read an error message, step by step
- Open the JSON Formatter and Validator and paste in the JSON.
- Choose Validate only. It checks the text without changing it, so the message describes the file exactly as you wrote it.
- Decide which of the two situations the message describes: a character that does not belong at that spot, or a comma missing between two items.
- Look at the reported spot, then look just before it. Check the nearest comma, quote or bracket upstream for the promise the text failed to keep.
- Fix that one thing, and only that thing, then validate again. Repeat until the file passes, and format it with a 2 or 4 space indent if you want the readable version.
Worked example: one object, broken two ways
Start with a small valid object:
{"name":"Ovatly","tools":250,"free":true}
Break it the first way, by deleting the comma after the first value:
{"name":"Ovatly" "tools":250,"free":true}
The message reports a missing comma. The parser finished the pair "name":"Ovatly", expected a comma, and instead found the next key already starting. The fix goes exactly where the reading suggests: in the gap between the two pairs.
Now break the original the second way, by adding a comma at the end:
{"name":"Ovatly","tools":250,"free":true,}
The message reports an unexpected character. The comma promised one more key, and the closing brace arrived in its place, so the brace takes the blame for the comma's broken promise. Delete the trailing comma and the file validates. Same object, two different messages, and in the second case the character named is not the character you edit.
Limitations and honest tradeoffs
Plain-words messages name the kind of problem and roughly where reading failed; they do not highlight the exact character to change, and they cannot know what you intended the file to say. Reading them well is a skill this guide teaches, but the judgement stays yours, and the tool offers no automatic repair.
The grammar being enforced is strict JSON. Trailing commas, single-quoted strings, unquoted keys and comments are all invalid, and there is no JSONC support, so files written for more forgiving parsers will fail here with the same two messages. That strictness is the point: a file that passes will be accepted by standard parsers everywhere.
Two smaller notes. Number precision follows JavaScript, so very large integers can lose exactness when text is reformatted; Validate only does not reformat, so it leaves your digits untouched. Very large pastes may take a moment to check. Everything runs fully locally in your browser.
Common mistakes
- Rewriting the whole file after one message. The message describes one fault. Fix that fault; a rewrite introduces new ones and destroys the evidence.
- Editing the character the message names. With a trailing comma, the reported brace is innocent and the comma before it is guilty. Read upstream before you edit.
- Declaring the file fixed after one round. The parser stopped at the first error, so others may be queued behind it. Validate until it passes, not until the first message disappears.
- Fixing three things at once. When the next message changes, you no longer know which edit mattered. One fix per round keeps the loop honest.
- Treating a familiar format as JSON. JavaScript objects and commented configuration look similar and fail here. The fix is converting the habits, not blaming the validator.
FAQs
My file has several mistakes. Why does the validator only show one? Because the parser stops at the first character it cannot read and cannot reliably continue past it. Fix that one problem and validate again. Each round surfaces the next mistake, and a file with three mistakes simply needs three rounds.
The message points at a line that looks correct. Where is the real mistake? Usually just before the reported spot. A trailing comma makes the closing brace look wrong, and an unescaped quote makes the words after it look wrong. Check the nearest comma, quote or bracket upstream of the reported character first.
What does a missing comma message actually mean? It means two items ran together: the parser finished one key and value pair, or one array value, and found the next item starting without a comma between them. The fix is to add the comma in the gap the message points to.
Does Validate only change my text while checking it? No. Validate only checks the text and reports the result, leaving every character as you pasted it. Formatting, with a 2 or 4 space indent, and minifying are separate actions you can run once the file passes.
Why does JSON reject comments and trailing commas that other formats allow? Because the JSON standard is deliberately strict and small: no comments, no trailing commas, double quotes only. This validator follows the standard with no JSONC support, so a file that passes here will be accepted by standard parsers elsewhere.
Conclusion
A validation message is a short report from the parser: what it expected, and where the text stopped providing it. Unexpected character means look at the spot and just before it; missing comma means two items need separating; and one message per round is how parsing works, not a flaw in the tool. Run the loop with the JSON Formatter and Validator until the file passes clean. For the most common cause of the first message, see How to Fix Unescaped Characters in a JSON String, and browse the rest of the series in the Data and JSON Tools guides.
References
- RFC 8259, the JSON data interchange standard, whose grammar these messages describe violations of: https://www.rfc-editor.org/rfc/rfc8259
- MDN Web Docs, on JSON syntax and how parsers handle it in JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON