JavaScript String Escaper / Unescaper

Escape text for embedding inside a JavaScript string (or unescape escaped contents). Uses JSON string rules for predictable results.

Input
Paste or type your content here…
Output
Your result will appear here

Frequently Asked Questions

Are quotes included?
Output is the string contents only - add your own surrounding quotes in source.
Template literals?
This targets classic string escaping; backticks/raw template needs may differ.