String Escape
Escape and unescape text for JSON, JavaScript, HTML, XML, CSV, SQL, shell and regex string literals, with error positions.
Escapes double quotes, backslashes and control characters. Unescaping works with or without the surrounding quotes.
Encoding URL parameters? Use URL Encode/Decode.
0 characters · 1 line
0 characters · 1 line
Shortcut: Ctrl/⌘ + Enter to swap
How to use
- Choose “Escape” to turn plain text into a string you can paste into code, or “Unescape” to turn an escaped string back into text.
- Pick the target language under “Format”, for example JSON, JavaScript, SQL or shell.
- Paste your text; the result appears instantly. If unescaping fails, the position of the problem is marked below.
- Click “Copy” to grab the result, or “Swap input and result” to convert the other way.
FAQ
Is my data uploaded?
No. Everything is converted in your browser.
Does SQL escaping prevent SQL injection?
Doubling ' to '' is standard SQL and fine for hand-written queries or data imports. In application code, always use parameterized queries (prepared statements) instead of building SQL strings yourself. Databases also differ: MySQL, for example, treats backslashes as escapes by default.
Why does shell escaping use single quotes?
In POSIX shells (bash, zsh, sh), nothing inside single quotes is interpreted, including $, `, \ and spaces, which makes them the safest choice. The only exception is the single quote itself, written as '\'': close the quotes, add an escaped quote and open them again. Unescaping also accepts double quotes and backslashes but never expands $variables.
How do JSON and JavaScript strings differ?
JSON allows only double quotes and fewer escapes (no \x, \v, \0 or \u{…}). JavaScript accepts single quotes, double quotes and backticks; in template literals (backticks) ${ starts an expression, so it is escaped too.
How do HTML text and attribute escaping differ?
Element content needs only &, < and > escaped; attribute values also need quotes escaped, or a quote would end the attribute early. Unescaping supports numeric references (中 and 中) and common named entities. For the full entity list, use the HTML Entities tool.
How do I escape a URL?
URL parameters use percent-encoding (like %20), which follows different rules than string escaping. Use the URL Encode/Decode tool.
Related tools
Unicode Escape
Convert text to \uXXXX, \u{…}, &#x…;, U+XXXX and other escapes or back, with each character’s code point and UTF-8 bytes.HTML Entities
Escape < > & and other characters as HTML entities or decode them back. Supports all 2,125 named and numeric references, with a quick reference.URL Encode/Decode
Percent-encode or decode URLs and query parameters, with full UTF-8 support and exact error positions.Regex Tester
Test JavaScript regular expressions live: highlight matches, list groups, preview replacements, with a syntax explainer and common patterns.