AZ Tools

String Escape / Unescape

Developer

One tool for the dozen contexts where strings need to be safe to embed: JSON literals, JS source, HTML attributes, SQL string literals, regex patterns, shell arguments. Each flavor has a real implementation (not a one-size-fits-all replace) — JSON uses `JSON.stringify`, JS handles `\u{...}` and `\xNN`, HTML uses entity refs, SQL doubles single quotes, regex escapes metacharacters, shell wraps in single quotes with the `'\''` trick.

Output
Output appears here as you type.

How to use

  1. Pick the flavor (JSON, JS, HTML, SQL, RegExp, Shell).
  2. Toggle escape ↔ unescape.
  3. Paste input, copy output.

Frequently asked questions

How is 'JSON' different from 'JS'?
JSON is a strict subset — no single-quoted strings, no `\x`, no `\u{...}`. The JS escaper produces what's valid in JS source; the JSON escaper produces what's valid inside a JSON string.
Does shell escape work for cmd.exe?
No — only POSIX shells (bash, zsh, sh). Windows cmd quoting is a different beast.
Is the regex escape Unicode-aware?
It escapes the dozen regex metacharacters the standard way. The result is safe to embed inside any regex flavor that uses the standard metaset.
Why does my SQL escape look fragile?
Doubling single quotes is the ANSI-standard escape and works in PostgreSQL, SQLite, modern MySQL with `NO_BACKSLASH_ESCAPES`. For untrusted input — always prefer parameterized queries.

Related tools