JSON Single Quotes Are Not Allowed – Fix the Error

If you write JSON with single quotes and try to parse it, you'll see an error like SyntaxError: Unexpected token ' in JSON at position 0 or Expected property name or '}' in JSON at line 1. The fix is straightforward: JSON requires double quotes for every string and every object key, without exception.

The rule: double quotes everywhere

The JSON specification (RFC 8259) defines a string as a sequence of Unicode characters wrapped in double quotes. This applies to both values and object keys:

// Invalid JSON — single quotes
{
  'name': 'Alice',
  'age': 30
}

// Valid JSON — double quotes
{
  "name": "Alice",
  "age": 30
}

Why does this trip developers up?

JavaScript allows both single and double quotes in object literals, so it is natural to write:

// Valid JavaScript object literal (NOT JSON)
const user = { 'name': 'Alice', 'age': 30 };

This works fine in JavaScript code, but the moment you try to pass that string as JSON — via an API, a config file, or JSON.parse() — it will fail. JSON is a stricter, language-independent text format and it does not inherit JavaScript's flexibility.

Apostrophes inside strings

A related question: if you cannot use single quotes as delimiters, what do you do when a value contains an apostrophe?

// An apostrophe inside a double-quoted string is fine — no escaping needed
{
  "note": "It's a beautiful day"
}

An apostrophe inside a double-quoted JSON string does not need to be escaped. Only double quotes inside a string value need a backslash escape:

{
  "message": "She said \"hello\""
}

Converting from single to double quotes

If you have a large block of single-quoted JSON-like text from a script or log output, a simple approach in most editors is a find-and-replace, but be careful — a global replace of ' with " will also replace apostrophes inside values. A more reliable approach:

  1. Paste the text into the JSON Validator — it will report the exact positions that fail.
  2. Fix the delimiters on keys and string values, leaving apostrophes inside values untouched.
  3. Validate again to confirm the document is now valid.

JSON vs JavaScript object literals

To summarize the key differences between JSON and a JavaScript object literal:

When you need to serialize a JavaScript object to JSON, always use JSON.stringify() — it produces valid JSON with double-quoted keys and values automatically.

Where single-quote JSON usually comes from

You rarely type invalid JSON on purpose, so it helps to know the usual sources. The most common is copying a JavaScript or Python object literal and treating it as JSON — both languages accept single quotes, so {'name': 'Alice'} looks right until a strict parser rejects it. Another is logging then re-parsing: Python's print(dict) and JavaScript's older console output render objects with single quotes, and pasting that log line back in fails. A third is hand-written config or test fixtures where a developer instinctively reached for the key that's easier to type. In every case the fix is the same — convert every string delimiter to a double quote — but knowing the source helps you fix it at the root instead of one file at a time.

Emitting correct JSON from code

The reliable way to avoid quote errors entirely is to never build JSON by hand. Let the language serialize it: JSON.stringify(obj) in JavaScript and json.dumps(obj) in Python always emit double-quoted, spec-compliant JSON regardless of how the object was written in source. If you're storing example JSON in a JavaScript file, remember that a JS object literal is not JSON — it just looks similar. Keep true JSON in .json files or template strings, and reserve object literals for actual code. When you do need to hand-edit a JSON document, paste it into the JSON Validator afterward; it flags the exact position of the first single quote so you can fix it before the file reaches an API or build step.

Try it directly in your browser — free, no signup:

Open JSON Validator →
About the author

Pasindu Ishan is a software developer based in Sri Lanka. He builds developer tools at JSON Dev Tools.