HomeJavaScript String Escape

JavaScript String Escape

Escape and unescape special characters in JavaScript strings, including quotes, newlines and control characters

Escape Options


Documentation

About JavaScript Escape / Unescape

This tool converts between plain text and JavaScript string literals. It is useful for code generation, log templates, and embedded config strings.

Key Features

  • Escape for JavaScript: Converts special characters into safe string sequences.
  • Unescape: Restores sequences like \\n, \\t, and \\uXXXX to real characters.
  • Option Controls: Supports Unicode output, slash escaping, and newline strategy.
  • Sample + Copy: Includes sample input and one-click copy.

Common Escape Rules

Source Escaped
\\ \\\\
" \\"
' \\'
newline \\n
tab \\t

Steps

  1. Enter plain text or escaped text.
  2. Configure options as needed.
  3. Click escape or unescape.
  4. Copy output from the result area.

FAQ

Why does unescape output look unexpected?

Make sure the input is a valid escape sequence string. Mixed raw backslashes and invalid sequences can change results.

When should I enable Unicode mode?

Use it when you need ASCII-safe output or stable cross-environment text transport.