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
- Paste the raw string you want to escape, or an already-escaped string you want to unescape.
- Choose the target format (JS/JSON, SQL, or Shell) and click the matching Escape or Unescape button.
- Copy the result directly into your source code, SQL query, or shell script.
Common use cases
- Embedding text in JSON: Escaping a multi-line string with quotes and newlines so it can be safely placed as a JSON string value.
- Building a SQL literal: Escaping single quotes in a user-provided name (e.g. O'Brien) before inserting it into a hand-written SQL string — though parameterized queries are always the safer approach in real applications.
- Writing a shell command: Quoting a filename or argument containing spaces or special characters so a shell script treats it as a single, literal argument.
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.