JSON Formatter & Validator

"Bad escaped character" in JSON: backslashes in Windows paths

Why C:\Users breaks JSON, the exact error messages in Chrome, Node.js and Python, and how to escape backslashes.

Error messages you may see

Chrome · Edge · Node.jsSyntaxError: Bad escaped character in JSON at position 13 (line 1 column 14)
Older Chrome · Node.js 18 and earlierSyntaxError: Unexpected token U in JSON at position 13
Python json.loadsjson.decoder.JSONDecodeError: Invalid \escape: line 1 column 13 (char 12)
This toolLine 1, Col 13: Invalid escape '\U'

Why it happens

A backslash starts an escape sequence in JSON, and only \" \\ \/ \b \f \n \r \t and \uXXXX are allowed. A Windows path such as C:\Users contains \U, which is not a valid escape.

Invalid

{"path": "C:\Users\kim"}

How to fix

Write each backslash twice (C:\\Users\\kim) or use forward slashes (C:/Users/kim), which Windows also accepts. Serializing with JSON.stringify() or json.dumps() escapes them automatically.

Fixed

{"path": "C:\\Users\\kim"}

Open this example in the JSON formatter →

Other common JSON errors