What it does
Takes a raw string and makes it safe to paste inside a quoted literal — or reverses the process. Pick a format, type or paste on the left, and the escaped (or unescaped) result appears on the right ready to copy. Switching formats or toggling Unescape re-runs instantly; nothing is sent anywhere.
The four formats
- JSON — escapes
",\and control characters (\n,\t,\rand the rest) exactly asJSON.stringifywould, then strips the surrounding quotes so you get just the string body. - JavaScript — the same as JSON but also escapes the single quote (
'→\'), so the result drops cleanly into either a single- or double-quoted JS string. - HTML — replaces the reserved characters
&,<,>,"and'with entities so the text renders as-is instead of being parsed as markup. For bulk entity work on accented or non-ASCII text, see the dedicated HTML entity encoder. - SQL — doubles single quotes (
'→'') so a value sits safely inside a single-quoted SQL literal.
Unescape
Tick Unescape to go the other way: JSON and JavaScript turn sequences like \n and \" back into real characters, HTML decodes named and numeric entities, and SQL collapses '' back to a single '.
Worked examples
The string He said "hi" followed by a newline becomes, in JSON mode, He said \"hi\"\n — paste that between quotes and it is a valid literal. In SQL mode the name O'Brien becomes O''Brien, so INSERT ... VALUES ('O''Brien') stores the apostrophe correctly.
Common gotchas
- SQL mode is a formatting helper, not an injection defence — use parameterised queries for untrusted input.
- When unescaping, paste the string body only, without the outer quotes, or JSON parsing will fail.
- HTML escaping here covers the five reserved characters; it won't convert accented letters to entities (that's what the non-ASCII option on the HTML entity tool is for).
When to use it
Reach for it when hand-editing a config or source file — embedding a snippet of HTML or a path inside a JSON value, pasting a quote-heavy sentence into a JS string, or dropping an apostrophe-laden name into a one-off SQL statement. For encoding values into URLs use the URL encoder, and for binary-safe text use Base64.
Privacy
All processing is local; nothing is uploaded.