The String Escape Tool converts a piece of text into a form that is safe to embed inside six different syntaxes at once — JSON, JavaScript, CSV, SQL, regex and the POSIX shell — and can reverse each one too. It is built for developers who are forever copying a tricky value (one with quotes, commas, newlines or backslashes) into a config file, a SQL console, a shell command or a regular expression, and want the escaping handled correctly the first time rather than debugging a mangled string later.
How it works
Pick a direction at the top. In Escape mode you paste raw text and the tool shows, for every target, the version you can safely embed. In Unescape mode you paste an already-escaped string and get the original text back. Results recalculate live as you type, and each target has its own copy button, so you can grab exactly the format you need. A filter box lets you narrow the list to a single target when you only care about, say, SQL.
Each target applies its real rule. JSON uses the browser’s own serialiser, so
control characters become \uXXXX and quotes, tabs and newlines are encoded exactly
as a valid JSON string body. JavaScript does the same but also escapes single
quotes and backticks so the body is safe inside '...', "..." or a template
literal. CSV follows RFC 4180: it only quotes a field that contains a comma,
quote or line break, and doubles any internal quote. SQL doubles single quotes,
the ANSI rule for string literals. Regex backslash-escapes every metacharacter so
your text matches itself literally. Shell wraps the value in single quotes and
rewrites internal single quotes, the bullet-proof POSIX way to pass an argument.
Example
Take the awkward value O'Brien, "the boss". Escaped for each target it becomes:
| Target | Escaped output |
|---|---|
| JSON | O'Brien, \"the boss\" |
| SQL | O''Brien, "the boss" |
| CSV | "O'Brien, ""the boss""" |
| Shell | 'O'\''Brien, "the boss"' |
Notice how the same input needs four completely different treatments. The CSV version gets wrapped and its quotes doubled because of the comma; SQL only touches the single quote; the shell version escapes the apostrophe but leaves the double quotes alone. Getting any of these by hand is easy to fumble — the tool does each one correctly and gives you a copy button per format. Everything is computed in your browser, so no text is ever uploaded or stored.