Are Single Quotes Allowed in JSON?

No. Single quotes are not valid in JSON. JSON requires double quotes for all keys and string values.
JSON strictly requires double quotes according to the official specification.

5 min readPython / JavaScript / PHP / curlUpdated April 2026

If you see errors like Unexpected token ' or parsing failures, this is usually the cause.

Invalid JSON:

{'name': 'Sam', 'age': 30}

Valid JSON:

{"name": "Sam", "age": 30}

Paste your JSON into the validator to detect and fix quote errors instantly using the JSON Validator.

JSON only accepts double quotes. Using single quotes will cause invalid JSON errors in most parsers. It does not matter what language you came from. If a key or string value is wrapped in single quotes, the parser rejects the whole payload. Here is what is happening, what the error looks like in each runtime, and how to fix it without breaking apostrophes.

Why the spec is this strict

JSON was designed to be boring on purpose. One part of that is strict quoting. Every parser, in every language, can agree on what counts as a string because the format only accepts double quotes.

JavaScript is what makes this feel slippery. In a JavaScript object literal, single quotes are fine. But a JavaScript object literal is not JSON. The moment that payload goes through JSON.parse(), json.loads(), or an API request body, the JSON rules win.

JSON5 does allow single-quoted strings. That can be useful in config files, but it does not change how strict JSON parsers behave. If the payload is headed to standard JSON tooling, JSON5 quote rules will still fail.

Invalid vs valid, side by side

These are the three versions people hit most often when they are copying JSON by hand or pasting code from another language.

Invalid: all single quotes

Both keys and values are wrapped incorrectly here.

Invalid: one single-quoted value is enough

Even one single-quoted string makes the whole payload invalid.

Valid: double quotes throughout

Once the keys and string values use double quotes, the parser is happy again.

Do not blindly replace every single quote. Apostrophes inside real text, like "user's name", are fine and should stay exactly as they are. The only quotes you want to replace are the ones acting as JSON delimiters.

What the error looks like per runtime

The exact message changes, but the root cause is always the same. The parser found a single quote where JSON only allows a double quote.

RuntimeError messageWhat it means
JSON.parseUnexpected token ' in JSON at position 2A key or string started with a single quote instead of a double quote.
json.loadsExpecting property name enclosed in double quotesPython is telling you the string looks like a dict literal, not strict JSON.
API clientInvalid JSON near key or opening characterThe parser stopped at the first place where the quote style made the payload invalid.

The same mistake looks different in each language

The rule never changes. What changes is the mental trap that gets you there. Pick the language you are coming from and compare the failing pattern with the safe one.

Python is the most common case. Dict literals use single quotes naturally, so it is easy to forget that json.loads parses strict JSON, not Python syntax.

Classic Python mistake

This string looks like a Python dict literal, but it is still invalid JSON.

Let json.dumps handle the quoting

If you start from a dict, serialize it instead of hand-writing JSON text.

How to fix it without breaking your data

A blind find-and-replace on ' to " is how people turn one parse error into two. Work in order instead.

  1. 1Identify the scope first. Are the keys wrong, the values wrong, or both?
  2. 2Replace only the single quotes acting as JSON delimiters.
  3. 3Leave apostrophes inside real text alone.
  4. 4Validate again immediately so hidden follow-up errors show up before you move on.

Apostrophes inside strings are still valid

This is valid because the string itself is still wrapped in double quotes.

Quick answers

What to do next

Start with the validator if the payload still fails. Once it passes, move to the formatter or jump sideways into the adjacent error guides.