String Escape Tool
Escape or unescape strings for JSON, JavaScript, Python, and regex.
Why escape strings?
Special characters like quotes, backslashes, and newlines have syntactic meaning inside string literals and pattern syntax. If you embed them unescaped, the parser sees the end of the string prematurely and produces a syntax error or, in the worst case, a security vulnerability like SQL injection or XSS. Escaping replaces special characters with their safe representations — a backslash followed by a code.
Frequently asked questions
What characters does JSON escaping handle?
JSON string values must escape: double quotes ("), backslashes (\), and control characters (newline \n, carriage return \r, tab \t, and characters 0x00–0x1f). All other Unicode characters can appear literally or as \uXXXX escape sequences.
When would I use regex escaping?
When constructing a regex pattern from user-supplied text, any character that has special regex meaning must be escaped. Otherwise a user searching for "1+1" would match "111", "11", etc. because + is a quantifier. The regex escape mode escapes all 12 metacharacters: . * + ? ^ $ ( ) | [ ] \
What is the difference between JSON and JavaScript escaping?
JSON requires double-quote delimiters and forbids single quotes inside string values without escaping. JavaScript template literals (backtick strings) need backtick and dollar-sign escaping instead of quote escaping. Use JSON mode when building JSON payloads; use JavaScript mode when building template literal strings in JS/TS code.
