Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
JSONTools / JSON errors / 'x' is an invalid escapable character within a JSO
System.Text.Json JsonDocument · .NET 8.0.30

'x' is an invalid escapable character within a JSON string. The string should be correctly escaped. LineNumber: L | BytePositionInLine: C.

This message comes from System.Text.Json JsonDocument on .NET 8.0.30. In this registry it is produced by 1 distinct mistake. Positions in the real message vary with your input; the causes do not.

What produces this message

Invalid escape sequence in a JSON string

Input
{"a": "c:\x41"}

Exact message: 'x' is an invalid escapable character within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 10.

Fix: Escape the backslash itself: write `C:\\Users`. Or use forward slashes, which Windows accepts in most APIs.

What other parsers say about the same input

If a colleague reports a different message for what looks like the same file, this is why.

Parser Message for the same inputs
CPython json.loadsInvalid \escape: line L column C (char N)
GsonInvalid escape sequence at line L column C path $…
Gson JsonParser (lenient off)Invalid escape sequence at line L column C path $…
JSON::PPillegal backslash escape sequence in string, at character offset N (before "…")
Jackson ObjectMapperUnrecognized character escape 'x' (code 120)
JavaScriptCore JSON.parseJSON Parse error: Invalid escape character x
Newtonsoft.Json JsonConvertBad JSON escape sequence: \x. Path 'a', line L, position N.
Newtonsoft.Json JsonTextReaderBad JSON escape sequence: \x. Path 'a', line L, position N.
SpiderMonkey JSON.parseJSON.parse: bad escaped character at line L column C of the JSON data
System.Text.Json Deserialize'x' is an invalid escapable character within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: L | BytePositionInLine: C.
V8 JSON.parseBad escaped character in JSON at position N (line L column C)
encoding/json Unmarshalinvalid character 'x' in string escape code
hjsonBad string at line L,10
json-bigintBad string
json_decodeSyntax error
orjsoninvalid escaped sequence in string: line L column C (char N)
serde_json::from_strinvalid escape at line L column C
ujsonUnrecognized escape sequence when decoding 'string'

← All JSON parser errors

Standards this registry is checked against

Only standards bodies and peer-reviewed venues are cited. Error strings on this site are observed by executing each parser; the standards above define what the parser is reacting to.