Invalid Escape Characters in JSON
JSON strings support a limited set of escape sequences: \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX (Unicode). Any other backslash sequence like \a, \x, or a bare backslash before a regular character is invalid. Windows file paths are a common source of this error.
Why It Matters
The JSON parser rejects the string with an invalid escape sequence. This is especially common with Windows file paths (C:\Users\...) and regex patterns stored in JSON.
Code Examples
{
"path": "C:\Users\john\documents",
"pattern": "\d+\.\w+",
"tab": "\t is ok but \a is not"
}{
"path": "C:\\Users\\john\\documents",
"pattern": "\\d+\\.\\w+",
"tab": "\t is ok"
}How to Fix
- 1Double every backslash in file paths: C:\\Users\\john instead of C:\Users\john.
- 2For regex patterns in JSON, escape every backslash: \\d+ instead of \d+.
- 3Use forward slashes for paths when possible: C:/Users/john/documents.
- 4Only use valid escape sequences: \", \\, \/, \b, \f, \n, \r, \t, \uXXXX.
Check Your JSON Now
Our JSON validator detects this error automatically and shows the exact line and column.
Open JSON ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated JSON APIs on reliable hosting.
Related JSON Errors
Single Quotes in JSON
JSON requires double quotes for all strings and keys. Learn how to fix the single quotes error.
Invalid Value Type in JSON
JSON only supports strings, numbers, booleans, null, objects, and arrays. Learn how to fix invalid value types.
Unexpected Token in JSON
Learn why JSON throws an unexpected token error and how to fix it. Common causes include trailing commas, single quotes, and unquoted keys.