String Escape
Escape strings for many languages.
About the String Escape
Escapes a block of raw text so it can sit inside a double-quoted string literal: backslashes are doubled, double quotes are backslashed, and newlines, carriage returns, tabs, form feeds, and backspaces become \n, \r, \t, \f, and \b. Those escapes mean the same thing in JavaScript, TypeScript, JSON, Java, C#, Go, and C. Unescape reverses all of it and also decodes \uXXXX sequences.
How to use the String Escape
- Paste the raw text into the input panel, or press Sample to load an example.
- Press Escape to produce a literal body, or Unescape to turn one back into raw text.
- Press Copy, or Download to save escaped.txt.
Frequently asked questions
- Are single quotes escaped?
- No, and they do not need to be inside a double-quoted literal in any of these languages. The output is safe to wrap in double quotes; if you plan to wrap it in single quotes in JavaScript or Python, escape those yourself.
- Does the output include the surrounding quotes?
- No. You get the body of the literal, so you add the quotes when you paste it into code.
- What happens to accented characters and emoji?
- They pass through unchanged rather than being converted to \uXXXX, which is valid in a UTF-8 source file. In the other direction, Unescape does decode \uXXXX if the input contains it.
- How is this different from JSON Escape?
- JSON Escape runs the text through JSON.stringify, so it also escapes the remaining control characters as \u00XX. This tool covers the named C-style escapes shared across languages.
- Is my text uploaded?
- No. Escaping is string manipulation in your browser tab, so a log line or a payload with credentials in it never leaves the machine.