Developer tools
String escaper
Escape text for JSON, SQL, shell, or regular expressions, or decode a JSON string back into plain text. Pick a target, paste your text, and copy the safely escaped result. Everything runs in your browser - nothing is uploaded.
How it works
Paste text and get it safely escaped for the context you are putting it into. Different languages reserve different characters: JSON needs quotes, backslashes, and control characters escaped; a SQL string literal doubles single quotes; a shell argument has to neutralise spaces and special symbols; and a regular expression has to escape the metacharacters that would otherwise change the pattern. Pick the target and the tool applies the right rules so the result drops straight into your code.
For JSON you can also go the other way and unescape a string back to its plain form, turning sequences like backslash-n and backslash-u escapes into the characters they represent. Everything runs in your browser, so the text you paste is never uploaded, and you can copy the escaped or unescaped result with one click.
Example. Escaping the line O'Reilly said "hi"\n for JSON produces O'Reilly said \"hi\"\\n with the quotes and backslash escaped; for SQL it becomes O''Reilly said "hi" with the single quote doubled. Switch the target to regex and a string like a.b*c is escaped to a\.b\*c so it matches literally.
FAQ
Which escape targets are supported?
JSON (escape and unescape), SQL string literals (single quotes doubled), shell arguments (wrapped and escaped so they are safe as one argument), and regular expressions (every metacharacter escaped so the text matches literally). Pick the target that matches where the string is going and the correct rules are applied.
What does escaping for a regular expression do?
It puts a backslash before every character that has special meaning in a regex - things like . * + ? ( ) [ ] { } ^ $ | and the backslash itself. The result is a pattern that matches your text literally, which is exactly what you want when you are searching for a fixed string that happens to contain regex metacharacters.
Can I unescape as well as escape?
Yes, for JSON. Paste a JSON-escaped string and the tool decodes the escape sequences - backslash quote, backslash backslash, backslash n, backslash t, and backslash-u hex escapes - back into the literal characters. Escaping is reliably reversible for JSON; the SQL, shell, and regex targets are one-way because their escaping depends on the surrounding syntax.
Is my text sent anywhere?
No. All the escaping and unescaping runs entirely in your browser as plain string manipulation. Nothing you paste is uploaded, logged, or stored, so it is safe to use with private code or data.