JSON Formatter
Paste any JSON below. format it, validate syntax errors, or minify for production. Everything runs in your browser.
Fix JSON Missing Comma Error
The missing comma is the #1 cause of JSON parse errors. You get an Unexpected token or Expected comma message but no clear pointer to where. Paste your JSON above. the formatter highlights the exact line and column so you can fix it immediately.
The Error Explained
{
"name": "Alice"
"age": 30
}{
"name": "Alice",
"age": 30
}["Alice" "Bob" "Carol"]
["Alice", "Bob", "Carol"]
{ "a": 1, "b": 2, }{ "a": 1, "b": 2 }{
"x": 1
"y": { "z": 2 }
}{
"x": 1,
"y": { "z": 2 }
}How to Fix It
- Paste your JSON into the input panel above and click Format
- Read the error: "Unexpected token X at line N, column M"
- Go to that line. the missing comma belongs between the previous property and this one
- Add the comma and click Format again to confirm it's valid
Comma Rules at a Glance
- Every property in an object needs a comma after it. except the last one
- Every item in an array needs a comma after it. except the last one
- Trailing commas (after the last item) are not allowed in JSON
- Commas go between values, never before the first or after the last
- Nested objects and arrays follow the same comma rules recursively
Frequently Asked Questions
What causes "Unexpected token" in JSON?
This error most often means a comma is missing between two properties or array items. The parser encounters the second value where it expected a comma, causing the unexpected token error.
How do I find the missing comma?
Paste your JSON into the formatter above. The error message shows the exact line and column of the problem. The missing comma typically goes just before the character at that position.
Is a trailing comma also invalid?
Yes. A trailing comma after the last item ({ "a": 1, }) is also invalid JSON, even though it works in JavaScript. Remove the final comma to fix the error.
Related Tools