Skip to content
Dev Utilities

Backslash escape

Escape and unescape string literals for code and config

0 chars
0 chars

JSON — how this mode behaves

RFC 8259 allows only \" \\ \/ \b \f \n \r \t and \uXXXX, so unescaping rejects anything else instead of guessing. U+2028 and U+2029 are escaped even though JSON permits them raw, because a document carrying them breaks when it is pasted into a <script> block.

Unescaping reads \n \t \r \\ \" \' \0, \xNN, \uNNNN and, where the language has them, \u{…}, \U0001F680 and octal escapes. A character written as a UTF-16 surrogate pair (\uD83D\uDE80) reassembles into the single character 🚀. Not supported: Python's \N{NAME} named characters, which are passed through unchanged, and bash $'…' ANSI-C quoting, which is reported as an error rather than half-decoded.