JS String Escaper — Free Online Tool

Escape raw text into a valid JavaScript string literal (\\n, \\t, quotes, control chars) or unescape a literal back to plain text. JS String Escaper is a free online tool from the ToolsRift JavaScript Tools collection. It runs entirely in your browser — nothing to install, no signup, and your data never leaves your device.

Loading JS String Escaper

How to use JS String Escaper

Choose Escape or Unescape, paste your text, pick the quote character, then click Convert and copy the result.

Frequently asked questions

What does escaping do?

Escaping turns special characters — newlines, tabs, quotes, backslashes and control characters — into their JavaScript escape sequences so the text can be safely pasted inside a string literal.

Is the conversion reversible?

Yes. Unescaping decodes \n, \t, \r, \b, \f, \v, \0, \xXX, \uXXXX and \u{...} back to the original characters, so escape then unescape returns your exact input.

Which quote should I pick?

Pick the quote you will wrap the string in. The escaper escapes only that quote character, leaving the other quote untouched for cleaner output.

More JavaScript Tools

JS Unicode Escaper
Escape non-ASCII characters to \\uXXXX sequences so source stays ASCII-safe, or decode \\uXXXX, \\u{...} and \\xXX back to text
JS Regex Escaper
Escape a literal string so its special characters are matched literally inside a RegExp, with optional forward-slash escaping
Template Literal → Concat
Convert ES6 template literals with ${expr} interpolation into equivalent string concatenation, string and regex aware
Ternary to If/Else
Expand ternary assignments, declarations and returns into readable if/else blocks, safely skipping ?? and ?. operators
List to JS Array
Turn a list of lines, comma or space separated values into a JavaScript array literal with quoting, trimming and de-duplication
JS Variable Name Validator
Check whether a name is a valid JavaScript identifier and explain each problem — digits, symbols, spaces or reserved keywords

← View all JavaScript Tools