String Escape/Unescape
Escape and unescape special characters for JavaScript, HTML, and URLs.
Report a Problem
Found a bug or have a suggestion? Help us improve this tool.
What is this tool?
String escape/unescape tool handles character escaping for various contexts. Escape special characters for JavaScript strings, JSON, HTML, CSS, and regular expressions. Also unescape encoded strings back to their original form. Prevents syntax errors and injection vulnerabilities in code.
How to use
- 1
Select context
Choose target (JavaScript, JSON, HTML, etc.).
- 2
Input string
Paste the text to escape or unescape.
- 3
Get result
Copy the escaped or unescaped string.
Frequently Asked Questions
Why do I need to escape strings?
Unescaped special characters (quotes, backslashes, newlines) break string literals in code. Escaping ensures the string is interpreted correctly by the parser. It also prevents injection attacks in HTML (XSS) and database queries (SQL injection).
Does it handle unicode?
Yes, unicode is properly escaped.
What characters need escaping in different contexts?
JavaScript strings: double quotes, single quotes, backslashes, newlines ( ), tabs ( ). JSON: double quotes, backslashes, control characters. HTML: < > & " ' (use < > & " '). Regular expressions: . ^ $ * + ? ( ) [ ] { } | \. Each context has its own set of special characters that must be escaped to be treated as literal text.
What is unescaping?
Unescaping is the reverse of escaping: it turns escape sequences back into the literal characters they stand for. The two-character sequence backslash-n becomes an actual line break, backslash-t a real tab, the & entity a plain ampersand, and the unicode escape for U+00E9 the accented letter é. You need it whenever you read text that another system stored in escaped form (log files, database dumps, or configuration strings) and want to display or parse it normally. This tool provides both directions, so you can escape output before saving and unescape it back when reading.