Fix expected double-quoted property name in JSON
What the 'expected double-quoted property name' JSON error means, how to read its position number, its common causes, and when automatic repair is safe.
The error "Expected double-quoted property name in JSON at position N" means a JSON parser reached a spot where it needed an object key and found something else. JSON requires every key to be a string wrapped in straight double quotes (U+0022). Single quotes, unquoted keys, curly quotes and a stray trailing comma all break that rule. This guide explains what the message is telling you, how to find the exact character, and how to judge whether a formatter or repair tool fixes the problem without changing your data.
Short answer: fix the source, use repair tools for diagnosis
A JSON validator or formatter is well suited to locating the bad character and showing the structure around it. Automatic repair, such as swapping quote styles or deleting trailing commas, works for a one-off file you can review by eye. It is a poor fit for a pipeline, because it hides the real defect: whatever produced the invalid text will keep producing it. The main tradeoff is that repair alters stored characters, and a blind rule can also alter string values. When the data comes from your own code, the dependable fix is to generate it with a real serializer instead of patching the output.
What the error means
Inside an object, a JSON parser expects either a closing brace or a double-quoted key after the opening brace, and a double-quoted key after every comma. If anything else appears at that point, parsing stops. The position number is the offset into the input string where the parser stopped, counted from zero.
Wording varies by engine and version. In current V8-based runtimes such as Chrome and Node.js, this exact phrase usually appears right after a comma. A bad first key tends to produce a differently worded message, such as "Expected property name or '}'". Firefox reports a similar "expected double-quoted property name" message with a line and column. Python's json module says "Expecting property name enclosed in double quotes" and gives line, column and character offset. Because the wording is not stable, treat the position as the reliable clue.
Common causes, with positions checked
Each example below is invalid JSON, and the position shown is the zero-based index of the character where parsing stops. Whitespace is counted in the index even though the parser skips over it.
{"a":1,}
// trailing comma: the parser expects a key after the comma and finds '}' at position 7
{"name":"Ada", 'role':"admin"}
// single-quoted key: the space at 14 is skipped, and the ' at position 15 is rejected
{"name":"Ada", role:"admin"}
// unquoted key: 'r' at position 15
{"id":1, “name”:"Ada"}
// curly opening quote U+201C at position 9; it looks like a double quote but is not one
- Trailing commas: left behind after deleting the last property, or copied from JavaScript, where they are legal.
- Single-quoted or unquoted keys: usually a JavaScript object literal pasted where JSON was expected.
- Python dict output: printing a dict with str() or repr() produces single quotes, and True, False and None, none of which are JSON.
- Comments: JSON has no comments, so a // or /* after a comma triggers the same error.
- Smart quotes: word processors, note apps and some chat or document tools may convert straight quotes to curly ones as you type or paste.
- Look-alike characters: fullwidth or styled quote marks from Unicode text-styling tools are separate characters, not decorative versions of U+0022.
What a formatter changes versus what a repair changes
These are two different operations that tools often bundle together.
| Operation | What changes | Effect on data |
| Pretty-print or minify | Whitespace between tokens only | None; parsing the output gives the same values |
| Validate | Nothing; it reports the error location | None |
| Quote repair (' to ") | Stored characters in keys and possibly values | Can corrupt strings that contain apostrophes or quotes |
| Trailing comma or comment removal | Stored characters | Safe only if the rule ignores text inside strings |
| Smart quote normalization | Replaces U+201C/U+201D with U+0022 | Can also rewrite curly quotes that legitimately belong inside string values |
Pretty-printing cannot run until the input parses, so a formatter that "fixes" invalid JSON is performing a repair first. Treat its output as edited data and compare it with the original before trusting it.
Finding the exact character
Print a small window around the reported position using an escaped form, so invisible or look-alike characters show up. Then print the code point of the character at that position. A straight double quote is 22 in hex. A curly quote shows as 201c or 201d.
// JavaScript
const i = 15; // position from the error message
console.log(JSON.stringify(text.slice(Math.max(0, i - 20), i + 20)));
console.log(text.codePointAt(i).toString(16));
# Python
import json
try:
json.loads(text)
except json.JSONDecodeError as e:
print(e.lineno, e.colno, repr(text[max(0, e.pos - 20):e.pos + 20]))
print(hex(ord(text[e.pos])))
Emoji and some other characters can shift the count. JavaScript string positions are counted in UTF-16 code units, so a single emoji outside the Basic Multilingual Plane occupies two positions. Python counts code points. In the example below, the closing brace sits at position 14 in JavaScript but at index 13 in Python. A text editor's column number may match neither. If the reported position seems to land in the wrong place, check for emoji or combining marks earlier in the line.
{"note":"👋", }
// JavaScript: '}' at position 14 (the emoji counts as 2)
// Python: '}' at index 13 (the emoji counts as 1)
Targeted fixes by cause
- Python dict text: serialize with json.dumps(data) instead of str(data). For text already in Python-literal form from a trusted source, ast.literal_eval can read it back so you can then dump it as JSON. Never use eval for this.
- JavaScript object literal: produce the text with JSON.stringify(value) instead of writing it by hand or building it with string concatenation.
- Trailing comma or comment in a hand-edited file: remove it at the reported position. If the file is a config format that officially allows comments, such as the JSON-with-comments style used by some editor and TypeScript config files, parse it with that format's own parser rather than a strict JSON parser.
- Smart quotes: turn off automatic quote substitution in the tool you write in, or replace U+201C and U+201D with U+0022 only in structural positions, then review string values.
- Unknown origin: validate first, fix by hand at the reported position, then re-validate. Repeat, because each fix may reveal the next error.
Avoid a global find-and-replace of ' with ". A value like "it's" becomes "it"s", which breaks the document in a new place or silently changes it. The same risk applies to a regex that strips ",}" or ",]" everywhere, since those character sequences can legitimately appear inside strings.
Will the fixed JSON survive copying and sharing?
Valid JSON is plain text, so it stays valid as long as nothing rewrites its characters along the way. The weak points are rich-text destinations. Document editors, email composers, slide tools and some messaging apps may substitute curly quotes or alter whitespace. Rendered Markdown can also mangle text outside a code block. Pasting into a code block, a plain-text field or an attached file keeps the characters intact. Whether a particular app converts quotes depends on its settings and version; this was not tested here, so check the pasted result with a validator.
Straight and curly quotes look alike and may be announced the same way, or not at all, by screen readers. Do not depend on spotting the difference by eye or by ear. A validator's position report or a code-point check works the same for every reader. Pretty-printed output with consistent indentation also makes the structure easier to follow line by line than a single minified line.
If you use a web-based validator or formatter, do not paste tokens, credentials or personal data unless you know how the tool handles input. A tool's appearance or marketing does not tell you whether it sends or keeps what you paste. A local parser, as in the snippets above, avoids the question entirely.
When strict JSON is the better choice
Lenient formats that allow comments, single quotes or trailing commas are convenient for hand-edited config files that have a dedicated parser. For data exchanged between programs, APIs or services, strict JSON is preferable. Every standard parser accepts it, and errors surface where the data is produced rather than downstream. If a lenient parser makes the error disappear, the receiving system may still reject the same text.
Limits of this guide
No specific validator, formatter or repair tool was evaluated, and no measurements or test results are reported. Error wording is described as typical of the named engines and may differ in other versions. The positions in the examples follow from counting the example strings. The behavior of particular editors or messaging apps when pasting quotes was not verified.