About String Escaper & Unescaper
Pasting a file path, a quote or a multi-line message into source code means getting every backslash and quote right for that language. Choose where the text is going and this tool writes it the way that language expects: \n and \t for JavaScript, octal codes for control characters in Java, doubled quotes for SQL and CSV, single quotes for a POSIX shell.
Switch to Unescape to go the other way: paste a string literal, with or without its quotes, and see the text it really holds. Invalid escapes are reported with their position instead of being guessed at.
How it works
- Backslashes, quotes and line breaks get the short escapes each language defines. Other control characters use a code the language reads unambiguously: \x00 in JavaScript and Python, three-digit octal in Java, \u0000 in C#.
- Add quotes wraps the result in double quotes, or single quotes for SQL, so it can be pasted as a complete literal. Escape non-ASCII characters writes accents and emoji as escape codes for source files that must stay ASCII.
- Shell arguments follow the rules of Python’s shlex.quote: safe words stay as they are, anything else goes in single quotes. CSV fields are quoted only when they contain the delimiter, a quote or a line break.
- Unescape removes one pair of outer quotes if present, then reads every escape. Each language’s own rules apply, including Java’s early reading of \u escapes and C# verbatim @"…" strings.
Questions
Does the SQL option protect against SQL injection?
It produces a correctly quoted literal, but the safe way to put values into a query is a parameterised statement. Use this for writing scripts and fixtures by hand, not for building queries from user input in an application.
What is the difference between SQL and MySQL here?
Standard SQL, PostgreSQL, SQLite, SQL Server and Oracle only double the single quote. MySQL and MariaDB, by default, also treat the backslash as an escape, so that option escapes backslashes, quotes, NUL, line breaks and Ctrl+Z as mysql_real_escape_string does.
Does unescaping a shell command run or expand anything?
No. Quotes and backslashes are removed and each word is shown on its own line, but $variables, `commands` and wildcards are left exactly as written. Nothing is run.
Can the JavaScript result go inside a template literal?
Yes. Backticks and the ${ that would start a substitution are escaped too, so the same text works between double quotes, single quotes or backticks.
How much text can it handle?
Up to 5 MB, processed on this page as you type. The text is never uploaded.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.