SyntaxError: Unexpected token ] in JSON at position 0: what it means and how to fix it
Troubleshoot SyntaxError: Unexpected token ] in JSON at position 0 quickly and validate JSON locally (no upload).
What the error means
SyntaxError: Unexpected token ] in JSON at position 0 means the parser expected valid JSON but encountered a character/token that cannot appear there. In practice, it usually means the input is not JSON (or not strict JSON), or it is incomplete.
Most common real-world causes
- There is a stray closing bracket at the start (copy/paste artifact).
- You are parsing a fragment that lost its opening { or [.
- A previous step concatenated JSON incorrectly and left extra closers.
Fast debugging steps
- If the string begins with a closing bracket, remove it or restore missing openers.
- If you expect an array/object, ensure the whole document is present (not truncated).
- Validate locally to pinpoint the next error.
Code example (node)
// Example: stray closing bracket
const bad = ']}\n{"a": 1}';
// Fix: remove the stray prefix or restore missing opening brackets
const ok = '{"a": 1}';
JSON.parse(ok);
Fix without uploading data
If the JSON contains sensitive data, validate and fix it locally. No Upload Tools runs 100% in your browser.
- JSON Validator to pinpoint the exact syntax error.
- JSON Repair to remove comments/trailing commas when the source is not strict.
- JSON Formatter to pretty-print and inspect structure.
- JSON String Escape if the issue is inside a string (newlines/tabs/quotes).
Workflow: validate -> fix the first error -> validate again -> export/convert.
FAQ
Does the exact token matter? Yes. The token often hints at the root cause: < is usually HTML, u is often undefined, and / often points to comments.
Should I just regex-fix JSON? Avoid blind regex edits. Validate after each change so you know what you fixed and what broke.