String Escape / Unescape
Escape or unescape text for JSON, JavaScript, Java and C#, Python, SQL, CSV, regular expressions, shell commands and XML. Turn quotes, backslashes, line breaks and tabs into the right escape sequences — or decode \n, \u00e9 and \" back into text.
This tool runs entirely in your browser.
How to use the String Escape / Unescape
- 1Paste the text.
- 2Choose Escape or Unescape and the language or format.
- 3Copy the result into your code, query or file.
What is the String Escape / Unescape?
Every language has characters that can’t appear raw inside a string literal. JSON, JavaScript, Java, C# and Python use backslash sequences (\" \\ \n \t \u00e9); SQL doubles single quotes (O''Brien); CSV wraps a field in quotes and doubles the quotes inside; regular expressions put a backslash before . * + ? ( ) [ ] { } | ^ $ \ / and -; and the shell mode wraps text in single quotes so nothing is expanded.
Escaping for SQL here is for writing literals by hand — in application code always use parameterised queries instead, which make escaping unnecessary and prevent SQL injection.
Frequently asked questions
What is the difference between JSON and JavaScript escaping?
JSON only allows double-quoted strings, so single quotes are left alone. JavaScript mode also escapes single quotes, backticks and $ so the result works in any kind of JS string, including template literals.
Why does unescaping JSON fail?
The input must be a valid JSON string body: every " and \ inside it must already be escaped, and \u must be followed by four hex digits.
Is the String Escape / Unescape free and private?
Yes. The String Escape / Unescape is free, needs no account, and runs entirely in your browser. What you type is never sent to a server or stored.
Related tools
All developer tools →- HTML Entity Encoder / DecoderEncode & < > " as HTML entities, or decode them.
- URL EncoderPercent-encode text for URLs.
- JSON FormatterFormat and beautify JSON online.
- Regex TesterTest regular expressions with live highlighting.
- Base64 EncoderEncode text to Base64.
- JSON ValidatorCheck if JSON is valid and find syntax errors.
