JavaScript String Escape & Unescape
Escape text for JavaScript single quotes, double quotes, or template literals and decode ECMAScript simple, hexadecimal, and Unicode string escapes entirely inside the browser.
JavaScript String Escape & Unescape workspace
Press Ctrl/Cmd + Enter to convert. Processing stays in this tab and input is limited to 500,000 characters.
JavaScript String Escape & Unescape example
Template-literal mode escapes the interpolation opener so the output remains literal text.
Example input
Hello ${name}
Unicode: 😀Expected output
`Hello \${name}\nUnicode: 😀`How to use JavaScript String Escape & Unescape
- 1
Choose Escape or Unescape.
- 2
For Escape, select double quotes, single quotes, or a template literal.
- 3
Choose whether to include delimiters and whether to escape non-ASCII code points.
- 4
Paste text and run the conversion or press Ctrl/Cmd + Enter.
- 5
Inspect template markers and Unicode output before copying or downloading.
What this tool does
Escape mode protects the selected delimiter, backslashes, line terminators, template interpolation markers, and control characters. Unicode can remain readable or become fixed-width or code-point escapes.
Unescape mode accepts single-quoted, double-quoted, backtick-delimited, or unquoted content. It decodes ECMAScript simple escapes, line continuations, two-digit hex values, four-digit UTF-16 code units, and brace-delimited Unicode code points.
The converter handles literal text without calling eval or Function. It distinguishes JavaScript string escapes from URL percent encoding and the deprecated global escape() format.
Features and options
- Single- and double-quoted output
- Template-literal output
- Automatic ${ interpolation protection
- Optional delimiters
- Simple ECMAScript escape decoding
- \xHH, \uHHHH, and \u{H...} support
- Unicode code-point output
- Line-continuation decoding
- No eval or remote API
Technical information
ECMAScript strings are sequences of UTF-16 code units. A four-digit \u escape represents one code unit, while \u{...} represents a Unicode code point and is encoded to one or two UTF-16 code units.
Single- and double-quoted literals cannot contain an unescaped matching quote, backslash, or physical line terminator. Template literals allow physical newlines but give backticks, backslashes, and ${ special meaning.
ECMAScript permits some identity escapes in ordinary strings, while numeric and Unicode forms have strict digit and range requirements. Deprecated legacy octal sequences are intentionally rejected.
Common use cases
- Embedding copied text in source
- Preparing JavaScript fixtures
- Protecting template interpolation markers
- Decoding console or JSON-adjacent samples
- Inspecting Unicode code-point escapes
- Making invisible controls reviewable
Limitations
- Tagged-template cooked/raw semantics are not evaluated.
- Legacy octal escape sequences are not supported.
- The tool converts JavaScript literal contents, not JSON strings, regular expressions, URLs, or HTML.
- It does not evaluate concatenation, expressions, or interpolation holes.
- Lone UTF-16 surrogate code units may remain as code units and should be reviewed for the target system.
Related tools
References & Sources
Defines ECMAScript string literal grammar, escape sequences, and resulting string values.
Verified 2026-08-13 ↗MDN Web Docs · Official DocumentationMDN JavaScript Lexical GrammarDocuments current JavaScript string literal delimiters, escapes, Unicode forms, and line continuations.
Verified 2026-08-13 ↗MDN Web Docs · Official DocumentationMDN Template LiteralsExplains backtick delimiters, interpolation markers, multiline text, and tagged-template escape behavior.
Verified 2026-08-13 ↗tc39.es · SpecificationECMAScript String ObjectsDefines the UTF-16 string values produced by JavaScript literals.
Verified 2026-08-13 ↗JavaScript String Escape & Unescape FAQ
Is this the same as encodeURIComponent or the old escape() function?
No. This tool handles JavaScript source-literal backslash escapes. URL percent encoding and the deprecated escape() function use different representations.
How are ${ markers handled in template mode?
The dollar sign is escaped so the generated template literal contains the characters ${ instead of opening an interpolation expression.
What is the difference between \uD83D\uDE00 and \u{1F600}?
The first writes the two UTF-16 surrogate code units explicitly; the second names the complete Unicode code point. Both can produce the same emoji string value.
Does unescape call eval?
No. It uses a deterministic parser and never executes JavaScript code or interpolation expressions.
Are invalid Unicode values rejected?
Yes. Incomplete fixed-width sequences, malformed brace escapes, values above U+10FFFF, and surrogate scalar values in code-point form are reported.
Can I use the output as JSON?
Only double-quoted output may look similar, but JSON has a different and stricter grammar. Use a JSON-specific validator when the destination is JSON.