JSON Error: Invalid String / Single Quotes
SyntaxError: Unexpected token ' in JSON at position XWhat Causes This Error?
JSON requires all strings — both values and object keys — to be enclosed in double quotes. Single quotes are not valid JSON, even though they work in JavaScript. This error typically appears as "Unexpected token '" and is most common when developers copy JSON from JavaScript object literals, Python dictionaries, or shell scripts that use single quotes.
Common Causes
- arrow_rightCopying a JavaScript object literal that uses single-quoted strings
- arrow_rightWriting JSON by hand and using single quotes out of habit
- arrow_rightCopying from a Python dictionary (which uses single quotes by default)
- arrow_rightShell scripts or curl commands that output single-quoted JSON
- arrow_rightA text editor that auto-converts double quotes to single quotes
Example: Broken vs Fixed JSON
cancel Invalid JSON (causes the error)
{
'name': 'Alice',
'role': 'admin',
'active': true
}check_circle Fixed JSON (valid)
{
"name": "Alice",
"role": "admin",
"active": true
}Step-by-Step Fix Guide
Replace single quotes with double quotes
Use Find & Replace (Ctrl+H) to replace all ' characters with ". Be careful not to replace apostrophes inside string values — only the outer delimiters should change.
Check keys and values separately
First fix all object keys, then fix all string values. Keys in JSON must always be in double quotes. String values in JSON must also be in double quotes.
Handle apostrophes inside strings
If a string value contains an apostrophe (e.g., "it's"), that apostrophe does not need to be escaped when the string is in double quotes. No changes needed there.
Validate
Run the fixed JSON through the JSON Validator to confirm no more single-quote errors remain.
Fix This Error Instantly
Paste your JSON into the validator to get the exact line number and error description. Then use the JSON Editor to make the fix and re-validate in one workflow.
Related JSON Errors
Part of the JSON Toolkit
Explore All JSON Tools
Free online tools for every JSON task — format, validate, convert, compare, and more.