Drop any text inside a code string without breaking it. Every language or format reserves certain characters (quotes, backslashes, <, &…); if your text contains them, you must escape them —swap them for a safe sequence— so they are treated as text, not as syntax. This tool escapes and unescapes for 7 different targets, 100% in your browser: nothing is uploaded to any server.
1. Pick the mode (the target format: JavaScript, JSON, SQL…).
2. Pick the direction: Escape or Unescape.
3. Paste your text into «Input text».
4. The Result shows below instantly; press the copy icon to grab it.
Changing mode or direction recomputes right away over the same text.
Prepares text for a JavaScript/TypeScript string. Escapes the backslash (\ → \\), the newline (→ \n), the carriage return (→ \r), the tab (→ \t), the null character (→ \0) and both quotes (" → \" and ' → \'). That way you can paste the result between quotes without accidentally closing the string.
Example: He said "hi" → He said \"hi\".
Builds the contents of a JSON string (without the outer quotes) via JSON.stringify. Escapes double quotes (→ \"), backslashes (→ \\) and every control character as a valid JSON sequence: newline → \n, tab → \t, return → \r, and others like \u001b. Wrap the result in double quotes and you have a valid JSON value.
Example: Ann said "yes" → Ann said \"yes\".
Escapes strings for standard SQL by doubling the single quote (' → ''), which is how SQL represents a literal quote inside '...'. It stops an apostrophe from closing the string early (a classic cause of syntax errors and SQL injection). It does not escape the backslash: standard SQL does not treat it as an escape character.
Example: O'Brien → O''Brien.
Turns your text into a pattern matched literally. It prepends a backslash to the regular-expression metacharacters —. \ + * ? [ ] ^ $ ( )
Escapes text so you can drop it inside HTML without the browser reading it as tags. Converts & → &, < → <, > → >, " → " and ' → '. Prevents XSS and keeps your content from breaking the page markup.
Example: <a href="x"> → <a href="x">.
Encodes text for a URL with encodeURIComponent: replaces unsafe characters with their %XX form. A space becomes %20, & becomes %26, = becomes %3D, and so on. Use it to put a value into a query parameter without breaking the URL. When unescaping, if the input is malformed it returns the text as-is without throwing.
Example: a b&c=d → a%20b%26c%3Dd.
Escapes text to use as a CSS identifier or value (for example inside a selector). It prepends a backslash to the CSS special characters: ! " # $ % & ' ( ) * + , . / : ; < = > ? @ [ \ ] ^ `
Escape turns the original text into its escaped version; Unescape does the reverse and recovers the original.
• Use the same mode to unescape that you used to escape.
• URL and JSON do not throw if the input is malformed: they return the text as-is.
• The result is computed automatically and saved; you can copy, export the text or import it from the toolbar.