JSON troubleshooting
Expecting property name enclosed in double quotes
Fix single-quoted strings and unquoted keys in JSON. Compare exact Python and JavaScript errors and serialize objects without unsafe quote replacement.
What the error means
Every JSON object property name must be a string enclosed in double quotes. String values also need double quotes. A JavaScript object literal or Python dictionary display can use syntax that looks like JSON but is not JSON text. The reported position is where the parser expected a quoted property name; a trailing comma can also produce a property-name error.
Exact messages by runtime
Messages depend on the input and runtime version. Node and Python rows were reproduced locally. Other rows cite official documentation or source. Rows marked as fragments or templates preserve the source wording and are not complete exception transcripts. Browsers and libraries may append location details.
| Runtime | Message | Input and evidence |
|---|---|---|
| Python | json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) | json.loads("{'id':1}") or json.loads('{id:1}')Reproduced in Python 3.14.4 |
| JavaScript / V8 | SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) | JSON.parse("{'id':1}") or JSON.parse('{id:1}')Reproduced in Node.js 24.21.0 |
| Firefox | SyntaxError: JSON.parse: expected property name or '}' | JSON.parse("{'foo': 1}")Exact example in MDN; location suffix omitted |
| Java / Jackson | was expecting double-quote to start field name | Unquoted key with default parser settingsExact diagnostic fragment from Jackson 2.18 source; exception prefix and location vary |
| C# / System.Text.Json | '{0}' is an invalid start of a property name. Expected a '"'. | Source template; {0} is the offending characterOfficial .NET 10 resource string, path and location suffix omitted |
Causes you can reproduce
A Python dictionary was converted with str
str(dict) produces Python syntax. Use json.dumps to produce JSON, including the correct quoting and boolean/null literals.
import json
text = str({'id': 1})
json.loads(text)A JavaScript object literal was copied as text
JavaScript permits unquoted identifier keys and single-quoted strings. JSON permits neither. JSON.stringify writes the correct JSON form.
JSON.parse("{id: 'Ada'}");A configuration file uses a different format
A file written with single-quoted keys may be intended for a permissive configuration parser. Confirm its format before feeding it to a strict JSON parser.
{'name': 'Ada', 'active': true}How to fix it
- Read the reported property name and the character before it. If the preceding comma is directly before }, check the trailing-comma guide.
- Use double quotes for every key and string value when editing a small JSON document.
- Fix the producer with JSON.stringify in JavaScript or json.dumps in Python.
- Validate the complete result. Avoid replacing every apostrophe with a quote because apostrophes can belong inside string values.
Serialize the JavaScript object
Single quotes can delimit a JavaScript source string. The resulting JSON text still needs double quotes around JSON keys and string values.
const text = JSON.stringify({ name: "O'Connor", active: true });
const data = JSON.parse(text);
// text is {"name":"O'Connor","active":true}Serialize the Python dictionary
json.dumps preserves apostrophes inside values and converts Python True and None to the corresponding JSON literals.
import json
text = json.dumps({"name": "O'Connor", "active": True, "note": None})
data = json.loads(text)Find the exact position with Tool Kumar
- Copy the exact input text, including its original whitespace. For HTTP failures, copy the raw response body.
- Open the Tool Kumar JSON validator and paste the text. The document stays in your browser.
- Read the line and column in the error or fixable-issue banner. For an invalid document, select Go to error to move the caret to that location.
- Inspect the preceding token as well as the marked character. A parser marks where it discovered the problem; the missing quote, separator or value can start earlier.
Python character offsets are zero-based, while its displayed lines and columns are one-based. V8 string positions count UTF-16 code units; Go offsets count bytes read. Unicode text can make these offsets differ. Use the original text and its line/column context rather than copying an offset between runtimes.
Tool Kumar can classify some input as fixable loose JSON. Review a proposed change before using the repair action, then validate the result against your API contract. For empty input, inspect the producer or response because there is no character to select.
Frequently asked questions
Can JSON use single quotes?
No. JSON keys and string values use double quotes. An apostrophe is allowed as ordinary content inside a double-quoted JSON string.
Why is a valid JavaScript object invalid JSON?
JavaScript object literal syntax permits unquoted keys and single quotes. JSON is a separate text format with stricter syntax. Serialize the object with JSON.stringify.
Should I replace every single quote with a double quote?
No. That can damage names, apostrophes and escaped content inside values. Serialize the source object or correct the syntax with knowledge of the document.
Can a trailing comma cause the same error?
Yes. After a comma in an object, the parser expects another quoted property name. If the next character is the closing brace, remove the trailing comma.
Related errors and tools
- JSON trailing comma errors in objects and arrays
- "undefined" or "[object Object]" is not valid JSON
- Bad control character in string literal in JSON
- All JSON error guides
- JSON syntax reference
Standards and diagnostic sources
RFC 8259 and ECMA-404 define JSON syntax. Diagnostic wording belongs to the parser. The table links each cited message to its source.