String Escaper
Free online string escaper. Escape and unescape special characters for JavaScript and JSON. All processing happens locally in your browser.
How to Use String Escaper
Enter Your Text
Type or paste the text you want to escape or unescape into the input panel.
Choose Direction
Click "JS Escape" to add escape characters (\n, \t, \", etc.). Click "JS Unescape" to convert escape sequences back to literal characters.
Copy the Result
The output appears instantly in the right panel. Copy it and use it in your JavaScript code, JSON strings, or wherever escaped text is needed.
Examples
Before (Raw Text)
Hello
World "Tab"After (JS Escaped)
Hello\nWorld\t\"Tab\"Frequently Asked Questions
What is string escaping?
String escaping adds backslash (\\) before special characters so they can be safely included in string literals. For example, a double quote inside a double-quoted string must be escaped as \" to prevent it from ending the string prematurely.
When do I need to escape strings?
You need to escape strings when embedding text in JavaScript/JSON string literals, writing regular expressions, or handling any text that contains characters with special meaning in the target context. Escaping ensures the text is interpreted as literal characters, not as code.
What characters are escaped?
This tool escapes: backslash (\\) → \\\\, double quote (") → \\", single quote (') → \\', newline → \\n, tab → \\t, and carriage return → \\r. These are the most common escape sequences used in JavaScript strings.
What happens if I unescape invalid sequences?
The tool handles common escape sequences (\\n, \\t, \\r, \\', \\", \\\\) safely. If the input contains invalid escape sequences, they may be left as-is or produce unexpected results. Always verify unescaped output before using it in production.
Common Escape Sequences
Here are the most commonly used escape sequences in JavaScript and JSON:
\\n— Newline\\t— Tab\\r— Carriage return\\"— Double quote\\'— Single quote\\\\— Backslash