JSON Unquoted Keys
In JSON, every object key must be a double-quoted string. Unquoted or single-quoted keys are invalid.
Common causes
- Writing JSON by hand and omitting quotes around keys.
- Copying JavaScript object literals (which allow unquoted keys).
- Using single quotes instead of double quotes.
How to fix
- Put double quotes around every key: "key": value.
- Replace single quotes with double quotes for keys and strings.
- Use a JSON formatter or validator to spot unquoted keys.
Examples
Bad
{ name: "test" }Good
{ "name": "test" }FAQ
- Can JSON keys be unquoted?
- No. The JSON spec requires keys to be double-quoted strings.
- Why does JavaScript allow unquoted keys but JSON does not?
- JSON is a data format meant to be strict and portable; JavaScript is a language with looser syntax.
Fix it now
Try in validator (prefill this example)