Expecting ',' delimiter

ErrorPython

json.decoder.JSONDecodeError: Expecting ',' delimiter: line 2 column 23 (char 24)

Where JSON.parse stops

{
  "quote": "she said "hi" to me",
  "id": 2

What it means

The parser finished one value and found the next one starting straight away, with no comma between them. Here is the trap. You get this same message when a comma is genuinely missing and when a string ended earlier than you meant it to. The second case is far more common, so check your quotes first.

Last verified on Python 3.9, 3.11, 3.12, 3.13 and 3.14.

It opens with the error marked. Nothing is uploaded. Find where the error is.

Usually
An unescaped double quote inside a stringA genuinely missing commaA colon typed as a comma
Fix
Escape every double quote that belongs inside a string as \", and add any comma that really is missing.

The fix

Escape every double quote that belongs inside a string as \", and add any comma that really is missing. If the reported column points at text that looks perfectly fine, read backwards from there for a quote that closed a string too early.

broken.jsonFails to parse
{
  "quote": "she said "hi" to me",
  "id": 2
}
JSON.parse stops at line 2, column 23.

Line 2: add \ twice.

fixed.jsonParses
{
  "quote": "she said \"hi\" to me",
  "id": 2
}
JSON.parse reads it.

How the message appears

Treat the position as an upper bound. An unterminated string moves it well past the real mistake.

Console
  • json.decoder.JSONDecodeError: Expecting ',' delimiter: line 2 column 23 (char 24)
  • json.decoder.JSONDecodeError: Expecting ':' delimiter: line 1 column 10 (char 9)

What causes it

  1. An unescaped double quote inside a string

    Check this one first. "she said "hi" to me" is not one string with quotes inside it. It is the string "she said ", then the bare word hi, then more text. The parser sees two values in a row, reports a missing comma, and points at innocent-looking text several characters past the real mistake.

  2. A genuinely missing comma

    Two keys or two array items with nothing between them. Usually a hand edit, or a merge that dropped a line.

  3. A colon typed as a comma

    This gives you the sibling message Expecting ':' delimiter instead. Python read a key, and what came after it was not a colon.

Worth knowing

Watch outNever build JSON by dropping text into a template with an f-string or %. The first value that contains a quote, an apostrophe-heavy sentence or a Windows path gives you this error. json.dumps escapes properly, and it is not slower in any way you will notice.

NoteThe sibling message Expecting ':' delimiter has the same shape. Something turned up where the parser knew one specific character had to go.

What you put into the tools never leaves your browser. We count page views and keep them for 90 days. Accept and we also remember this browser, so a return visit is not counted as new. Privacy policy