Unquoted Property Keys in JSON
In JavaScript, object keys don't need quotes if they are valid identifiers. In JSON, every key must be a double-quoted string, no exceptions. This is one of the most common mistakes when converting JavaScript objects to JSON.
Why It Matters
The JSON parser fails at the first unquoted key. This is a frequent source of bugs when developers manually write JSON or copy JavaScript objects into .json files.
Common Causes
- Copying a JavaScript object literal where keys are bare identifiers like name or age.
- Hand-writing JSON and forgetting that keys, not just values, must be quoted.
- Converting from YAML or another format whose serializer left keys unquoted.
Code Examples
{
name: "John",
age: 30,
isActive: true
}{
"name": "John",
"age": 30,
"isActive": true
}How to Fix
- 1Wrap every property name in double quotes.
- 2Use JSON.stringify() in JavaScript to automatically generate valid JSON from an object.
- 3If converting from YAML or another format, ensure keys are quoted in the output.
- 4Configure your editor to highlight JSON syntax errors with a JSON language mode.
Frequently Asked Questions
Why does JavaScript allow unquoted keys but JSON does not?
What is the fastest way to quote all my keys correctly?
Can a JSON key be a number or contain spaces?
Check Your JSON Now
Our JSON validator detects this error automatically and shows the exact line and column.
Open JSON ValidatorCloudways · Managed Cloud Hosting
Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean).
Free 3-day trial · 30% off 3 months + free site migration with code MIGRATE303
Related JSON Errors
Single Quotes in JSON
JSON requires straight double quotes for every string and key, so single quotes always break parsing. Learn how to fix the single quotes error fast.
Unexpected Token in JSON
Fix the unexpected token error in JSON fast. See why parsers fail on trailing commas, single quotes, unquoted keys, and comments, with clear examples.
Trailing Comma in JSON
Fix the trailing comma error in JSON quickly. Unlike JavaScript, JSON forbids a comma after the last element, and our examples show you exactly how.