Code Escape / Unescape
Pick a language, paste text, and escape or unescape it for a string literal.
Setup
Paste source text, pick sample, and run escape or unescape.
Input
Use the matching language context to avoid over-escaping and copy-ready errors.
Escapes string contents for JSON; add surrounding double quotes when inserting a complete JSON string value.
Result
Converted string ready to copy or download.
Output
Escape text for a string literal
Each language escapes different characters: JSON and JavaScript escape quotes, backslashes and control characters, XML escapes markup characters, and SQL doubles single quotes. Pick the language you are pasting into so the result is neither under- nor over-escaped.
A computer once beat me at chess, but it was no match for me at kick boxing.