Developer tools

String escape and unescape

Escape text for a JSON, JavaScript or SQL string, or turn escaped text back into plain text.

Runs in your browser. Nothing you enter is uploaded.

About this tool

The string escape tool converts text into a valid JSON, JavaScript or SQL string literal, and converts escaped text back. JavaScript output is meant for single-quoted strings: single quotes are escaped, double quotes stay as they are, and the U+2028 and U+2029 line separators become \u escapes. SQL mode doubles single quotes.

Which escape sequences does unescape understand?
It reads \n, \r, \t, \b, \f, \v, \0, \xHH, \uHHHH and \u{...}. A broken \u or \x sequence shows an error instead of guessing.
Does SQL mode protect against SQL injection?
It only doubles single quotes so the text fits inside a quoted SQL literal. In application code, parameterized queries are the safer choice.