HTML Runner

JavaScript String Escape

Turn arbitrary text into a quoted JavaScript string, or decode a JSON-compatible string literal.

How to use JavaScript String Escape

Encode multiline text, then paste the quoted result into a JavaScript assignment. For decode, include the double quotes.

Limitations

Decoding accepts JSON string syntax. Single-quoted literals, template literals and JavaScript expressions are outside this tool’s scope.

Frequently asked questions

Why does a less-than sign become an escape?

Escaping it prevents text from accidentally closing a script element when used in inline JavaScript.

Test your web code in the live HTML workspace.

Related resources