</>
ValidateHTML

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

Invalid JSON
{
  "path": "C:\Users\john\documents",
  "pattern": "\d+\.\w+",
  "tab": "\t is ok but \a is not"
}
Valid JSON
{
  "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 Validator
Recommended

Hostinger Fast & Affordable Web Hosting

Deploy clean, validated JSON APIs on reliable hosting.

Get 80% Off Hosting →

Related JSON Errors

View all JSON errors