Skip to content
jsonbeautifiers
English
Python Verified by running the parser on CPython 3.14.3.

Invalid \escape: line L column C (char N)

A backslash in a JSON string is followed by a character that is not one of the nine JSON escapes. In Python code the confusion is doubled, because the Python string literal consumes backslashes too, so the text reaching the parser is not what you typed.

Paste your JSON and see exactly where it breaks

Input

Nothing you paste leaves your browser. The connect-src allowlist makes that a browser guarantee rather than a promise. Check it yourself

What actually causes it

Ranked by how often each one turns out to be the answer.

  1. 01 A Windows path

    Every backslash needs doubling for JSON, and in a non-raw Python literal it needs doubling again for Python. Using a raw string removes one layer of that.

    Breaks

    json.loads('{"p": "C:\Users"}')

    Works

    json.loads(r'{"p": "C:\\Users"}')
  2. 02 A regular expression

    \d, \s and \w are not JSON escapes. Double each backslash.

  3. 03 A \x hex escape

    JSON only has \uXXXX. \x41 must become \u0041.

The same mistake in other runtimes

The underlying problem is identical; only the wording differs. If a colleague reports one of these, they are looking at the same thing you are.

JavaScript (V8) Bad escaped character in JSON at position 9 (line 1 column 10)

Questions

Why does the same string work in one place and not another?
Because of how many times it passes through a string literal. A path written directly in a .json file needs one level of doubling. The same path inside a Python literal inside a shell argument may need three.
Is this the same as the SyntaxWarning about invalid escape sequences?
No, and they are easy to confuse. That warning is Python complaining about your source code, before any JSON is involved. This error comes from the JSON parser about the content of the string.

Fix it now

Paste the payload into the tool above, or go straight to the one built for this job.

Escape it correctly