String escape / unescape

Turn text into a safe string literal for JSON, JavaScript, regex or shell, or decode escape sequences like \n and \u00e9.

JSON escape sequences

SequenceCharacter
\"Double quote
\\Backslash
\nNewline (LF)
\rCarriage return
\tTab
\b \fBackspace, form feed
\u00e9Any UTF-16 code unit (é)

Regex escaping

Characters . * + ? ^ $ { } ( ) | [ ] \ / have special meaning in a regex. Escaping them lets you search for literal text such as a file name report(1).pdf.

Shell escaping

Inside single quotes nothing is special except the single quote itself, which is written as '\'' (close, escaped quote, reopen).

Frequently asked questions

Why do Windows paths need double backslashes?
In JSON and JS strings a single backslash starts an escape sequence, so C:\temp must be written C:\\temp.
Does JSON allow single-quoted strings?
No. JSON strings use double quotes only; a single quote inside does not need escaping.