Direction

Result

Paste text to escape or unescape it.

How to use this tool

  • Choose Escape or Unescape and a format.
  • Paste the text. The result updates as you type.

How it works

  • JSON: quotes, backslashes and control characters become \", \\, \n and so on.
  • JavaScript: as JSON, plus single quotes, backticks and ${ so the text is safe in any kind of quotes.
  • SQL: single quotes are doubled (O''Brien).
  • CSV: the value is wrapped in double quotes and inner quotes are doubled.
  • Regex: characters such as . * + ? ( ) [ ] get a backslash so they match literally.
  • Unicode: non-ASCII characters become \uXXXX.
  • XML: & < > " ' become entities.

Example

SQL

O'Brien escaped for SQL is O''Brien.

Regex

1.5*(x) escaped for a regular expression is **1\.5\*\(x\)**.

Privacy and limitations

  • Everything runs in your browser; nothing you paste is uploaded or stored.
  • Escaping for SQL is no substitute for parameterised queries, which prevent SQL injection properly.

Frequently asked questions

Why does unescaping JSON fail?

The text must be the inside of a valid JSON string: quotes and backslashes must already be escaped, and line breaks written as \n.

How are emoji escaped?

As two \u escapes (a surrogate pair), as JSON and JavaScript require: πŸ˜€ becomes \uD83D\uDE00.