DevTools Hub

Search tools

Search for a developer tool

Encoding

Text Escape

Escape or unescape text for JSON, JavaScript, or SQL string literals.

Part of the Encoding Toolkit
Escaped text

Minimal escaping, not hex

This escapes only the characters that actually need it to safely embed text in a string literal — quotes, backslashes, and control characters like newlines and tabs — leaving everything else, including accented letters and emoji, untouched and readable. For encoding every character (to \xHH, \uHHHH, &#xHH;, or a SQL hex literal), see Hex Encode instead.

FAQ

Why does JavaScript mode escape backticks even for single-quoted strings?

So the same output works no matter which of the three JS string forms it ends up in — one escape produces a value that's safe everywhere, rather than needing to pick a quote style up front.

Does SQL mode handle backslash escaping too?

No — only single-quote doubling, the portable ANSI SQL approach. MySQL's non-standard backslash escaping (outside ANSI_QUOTES mode) isn't handled here, since doubling works correctly there too and stays portable to every other engine.

Try it yourself

For full per-character hex or Unicode escape sequences instead of minimal escaping, see Hex Encode. For HTML/XML entity escaping specifically, see HTML Encode.

Related tools