Why JSON Requires Double Quotes

The specification reason JSON rejects single quotes and unquoted keys, the five errors that cause most JSON failures, and how to fix them quickly.

Short Answer

The JSON specification defines one string syntax: a sequence of characters wrapped in double quotation marks. Nothing else is legal. Single quotes, unquoted property names, trailing commas, and comments are all rejected by conforming parsers, even though JavaScript happily accepts most of them in object literals.

Where the Rule Comes From

JSON is standardised in RFC 8259 and ECMA-404. The grammar defines a string as a quotation mark, a sequence of permitted characters or escape sequences, and a closing quotation mark. Property names reuse exactly the same string rule.

There is no alternate branch for apostrophes. A parser that accepted them would be lenient, not correct, and interoperability would suffer: a document that works in one tool could fail in a database import, an API gateway, or another language's standard library.

Why Developers Get Confused

JSON's syntax was borrowed from JavaScript object literals, so the two look nearly identical. JavaScript, however, permits single-quoted strings, unquoted identifier keys, trailing commas, and comments. Every one of those habits is invalid the moment the same text is sent to a strict JSON parser.

A quick mental model helps: JSON is a data interchange format that happens to look like code, not code itself. Write it as data and the errors disappear.

The Five Errors Behind Most JSON Failures

  • Single quotes: {'name': 'Ada'} is invalid. Use {"name": "Ada"}.
  • Unquoted keys: {name: "Ada"} is invalid. Keys must be double-quoted strings.
  • Trailing commas: a comma after the last item in an object or array is invalid, even though JavaScript allows it.
  • Comments: JSON has no comment syntax. Remove // and /* */ before parsing.
  • Special values: undefined, NaN, and Infinity are not valid JSON values. Use null or a string instead.

How to Fix a Broken Payload Quickly

  1. Paste the document into the JSON Formatter. It validates syntax and reports the position of the first error.
  2. Look at the reported line, then check the token immediately before it. An unterminated string, a missing comma, or a stray quote is usually one character to the left of the complaint.
  3. Fix the first error only, then re-validate. Parsers stop at the first failure, so later errors are often caused by the first one.
  4. When the document is valid, format it once to make remaining punctuation mistakes obvious.

When Single Quotes Are Acceptable

Tooling ecosystems have built lenient formats on purpose. JSON5 allows single quotes, comments, and trailing commas for human-edited configuration. YAML avoids braces entirely and became the default for many deployment files. Those formats are fine where the consuming tool documents support for them.

The rule still stands at boundaries: HTTP APIs, JSON Schema validation, database drivers, and anything labelled "JSON" in a specification will expect strict RFC 8259 syntax. If a config file using JSON5 must be sent to a strict service, convert it first with a tool such as the JSON and YAML Converter or the JSON Formatter after correcting the syntax.

Why This Matters Beyond Syntax

Quoting errors are the most common cause of failed API calls during integration work, and the error messages rarely say "you used an apostrophe." They report an unexpected token at an offset that feels unrelated. Understanding that JSON has exactly one string syntax turns a confusing hunt into a one-minute fix.

Related Guides and Tools

The JSON Formatting Safety Guide covers redaction and debugging workflow. For conversions, use JSON to TypeScript, JSONPath Tester, or JSON and YAML Converter.

Quick Answers

Can JSON use single quotes?

No. The JSON specification only permits double quotes around strings and property names. Single quotes and unquoted keys are invalid JSON.

Why does JSON look like JavaScript but reject JavaScript syntax?

JSON was inspired by JavaScript object literals but deliberately kept a smaller grammar so every language can parse it identically. JavaScript accepts shortcuts that JSON does not.

Is JSON5 valid JSON?

No. JSON5 is a separate superset that allows single quotes, comments, and trailing commas. It is useful for configuration files read by tools that support it, but APIs and standard parsers will reject it.

What is the fastest way to find a quoting error?

Paste the document into a JSON formatter and read the reported position. If that spot looks correct, inspect the character just before it, which is where unterminated strings usually begin.