String Escape / Unescape

About the String Escape / Unescape

Different languages and systems have different rules for escaping special characters inside string literals — JavaScript/JSON uses backslashes, SQL doubles up single quotes, and shell scripts need careful quoting to avoid injection or syntax errors.

This tool escapes and unescapes strings for the most common targets — JavaScript/JSON, SQL, and shell — so you can safely embed arbitrary text into code or queries.

How it works

Common use cases

Frequently asked questions

Should I use SQL escaping instead of parameterized queries?

No — this tool is useful for understanding escaping or building one-off queries, but production code should always use parameterized queries or prepared statements, which eliminate SQL injection risk far more reliably than manual escaping.

What does JS Escape actually produce?

It wraps your string in double quotes and escapes characters like quotes, backslashes, and newlines using `JSON.stringify`, producing a value that's valid as both a JSON string and a JavaScript string literal.

Why did Unescape fail on my input?

JS Unescape expects a quoted string (starting and ending with ") — if your input isn't wrapped in quotes, wrap it yourself first, or the tool will attempt to interpret the raw text as JSON.

How does Shell Escape handle special characters?

It wraps the entire string in single quotes and safely escapes any single quotes within it, which is the most robust way to pass a literal argument through POSIX shells like bash and zsh.

This tool runs entirely in your browser — nothing you enter is sent to a server. Read more in the Privacy Policy, or browse the full list of tools.