0

String Escaper — JSON, JS, SQL & Regex

Escape or unescape strings for JSON, JavaScript/TypeScript, SQL and regex — live, entirely in your browser.

Need HTML entity or URL encoding instead? Use our HTML & URL Encoder / Decoder tool.

Processing... 0%

Result

Need to drop a string with quotes, backslashes or line breaks into a JSON payload, a JavaScript source file, a SQL query or a regular expression pattern? Each of those four contexts escapes special characters differently, and getting it wrong breaks the value or introduces a bug. This tool escapes and unescapes text for all four, live, right in your browser. Need HTML entity or URL encoding instead? Use our HTML & URL Encoder / Decoder — this tool deliberately leaves those two formats to it.

Pick a format and the rules switch instantly: JSON mode uses the exact escaping the JSON spec requires (quotes, backslashes, newlines, tabs and control characters); JavaScript mode adds a quote-style choice, so you get single-quote, double-quote or backtick-correct output, including template-literal ${ escaping; SQL mode doubles single quotes the way standard SQL string literals expect; and regex mode escapes the twelve special regex metacharacters so the exact literal text matches inside a new RegExp() pattern — regex escaping only goes one way, since there is no ambiguity to reverse.

One honest caveat: SQL string-doubling is shown here for learning and for quick one-off scripts, never as a substitute for parameterized queries or prepared statements — string-escaping user input by hand is a classic SQL-injection risk in real applications, and the tool says so plainly whenever SQL mode is active. Every conversion runs locally: nothing you paste, encode or decode is ever uploaded.