JavaScript String encoding - Online tool

Enter/paste text to replace special characters with correct escape codes:

Result JavaScript String with correct escape codes:

About the JavaScript String encoding

The String encoding tool converts all special characters and HTML entities to the correct String escape codes, for use in JavaScript.

The result is a single line, with standard ASCII characters, that can be pasted directly into your source code.