errorJSON Error Reference
Very Common

JSON Error: Invalid String / Single Quotes

SyntaxError: Unexpected token ' in JSON at position X

What 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

1

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.

2

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.

3

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.

4

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

Fix JSON Single Quote Error – Use Double Quotes