String escaper. Both ways, nine formats.
🔒 Your text never leaves your browser. Nothing is uploaded.
What each format escapes
| Format | Escapes | Example |
|---|---|---|
| JSON | " \ and control chars (\n, \t, …); non-ASCII optional | He said "hi" → He said \"hi\" |
| JavaScript | quote char, \, newlines; template mode also ` and ${ | it's → it\'s |
| HTML | & < >, optionally " ' and non-ASCII | a<b → a<b |
| URL | reserved & unsafe chars → percent-encoding | a b → a%20b |
| Base64 | everything → A-Z a-z 0-9 + / (UTF-8 safe) | hi → aGk= |
| SQL | single quote doubled (''); MySQL mode uses backslashes | it's → it''s |
| CSV | field quoted if it holds delimiter / quote / newline; " doubled | a,b → "a,b" |
| Regex | . * + ? ^ $ ( ) [ ] { } | \ optionally - / | 1+1 → 1\+1 |
| Unicode | chars → \uXXXX or \u{…} escapes | é → é |
How to use the String Escaper
The String Escaper converts text into the escaped form a format needs, and back again. It covers nine formats: JSON, JavaScript, HTML, URL, Base64, SQL, CSV, Regex and Unicode, each with its own options. It is for developers and anyone pasting text into code, a query, a link or a spreadsheet who needs quotes, slashes and special characters handled correctly.
Step by step
-
Pick a format
Press JSON, JavaScript, HTML, URL, Base64, SQL, CSV, Regex or Unicode. JSON is selected when the page opens. The reference table What each format escapes, under the tool, shows what each one changes with a short example.
-
Choose a direction
Press Escape to encode plain text, or Unescape to turn escaped text back into plain text. Escape is selected first.
-
Type or paste your text
Enter text in the Input box. The result appears in Output a moment after you stop typing, and the character count of both boxes shows above them.
-
Set the options for that format
The options row changes with the format. For example, JSON and JavaScript offer Include surrounding quotes, JavaScript has a Quote style menu, URL has a Function menu and Spaces as + (form style), SQL has MySQL backslash style, CSV has a Delimiter menu and Always quote field, and Unicode has Scope and Format menus.
-
Copy, download or chain
Press Copy output to copy the result, or Download .txt to save it as a file named after the format and direction, such as json-escaped.txt. Swap input/output moves the result into the Input box so you can run another step, and Clear empties both boxes.
Reading the result
- JSON escaping turns He said "hi" into He said \"hi\". Tick Include surrounding quotes to get a complete JSON string with the outer double quotes.
- URL with encodeURIComponent turns a space into %20 and also encodes characters such as / ? & and =, which suits a single query value. encodeURI leaves those alone, which suits a whole address.
- Base64 turns hi into aGk=. It encodes the text as UTF-8 first, so accents and emoji survive the round trip. The URL-safe option uses the minus sign and the underscore in place of + and /, and drops the trailing = padding.
- SQL doubles single quotes by default, so it's becomes it''s. MySQL backslash style writes it\'s instead and also escapes backslashes and line breaks.
- If you unescape text that is not valid for the format, such as broken JSON or a stray % in a URL, the Output stays empty and a red line under it says what went wrong.
Tips and common mistakes
- Swap input/output keeps the same direction. To check a round trip, press Swap input/output and then press Unescape, or you will escape the text twice.
- CSV mode treats everything in the Input box as one field. Use it to quote a single value, not to convert a whole file.
- Escaping SQL strings by hand is a stopgap. In application code, pass values as query parameters instead.
- HTML escaping covers the characters that break markup. Unescape decodes any entity your browser knows, named or numeric.
- In Unicode mode, the default \uXXXX format splits emoji into two surrogate escapes. Choose the code point format if your language supports it.
Privacy and limits
Every conversion runs in your browser with plain JavaScript. Nothing you type is sent anywhere or saved, so it is safe for tokens and passwords, and the boxes are empty again when you reload the page.
One tool, every escape.
\uXXXX.encodeURIComponent / encodeURI.\uXXXX / \u{…} code-point escapes..txt, or swap input and output to chain conversions.Frequently asked questions.
Is the String Escaper free?
Is it private? Is my text uploaded anywhere?
Does it work offline?
Which formats does it support?
What is the difference between JSON and JavaScript escaping?
${ interpolation marker.Does Base64 handle emoji and non-English text?
Published · Last updated .