Only single quotes escaped
Some tools miss backticks used in template literals.
Fix: This tool escapes ', ", and ` together to keep output safe for any literal type.
header • up to 320x100 / 728x90
Escape or unescape JavaScript string literals with backslash, quote, Unicode, and control-character handling
Output will appear here...
content bottom • up to 300x250
sidebar • 160x600
Last reviewed:
JavaScript is the programming language of the web, running in every modern browser and powering most interactive frontends and Node.js backends.
JavaScript Escape / Unescape turns arbitrary text into a safe string literal (escaping \, ", ', `, newlines, tabs, and control characters) or reverses the operation by interpreting \n, \t, \x, \u, and \u{...} sequences.
It is the go-to helper for embedding user input in generated JavaScript, debugging minified code, and sharing snippets between code reviews and documentation.
He said "Hi" <3 Tab: done
He said \"Hi\" <3\nTab:\tdone
Some tools miss backticks used in template literals.
Fix: This tool escapes ', ", and ` together to keep output safe for any literal type.
Characters above U+FFFF need surrogate pairs.
Fix: Use \u{...} for emoji or astral code points.
Yes — both, plus backticks, to support template literals.
\xNN, \uNNNN, and \u{H..H} for astral code points.
Yes. Backticks are escaped on output so the result is safe inside template literals.
No — escape / unescape runs entirely in your browser.
No. Only escape sequences are added or removed.
Pair JS escape with JSON, HTML, and SQL escape helpers for complete encoding workflows. You can also browse the full Encoders & Decoders category for more options.
Escape JSON special characters
Round-trip Java string literals — escape quotes, backslashes, newlines, and Unicode sequences
Escape or unescape C# string literals including \x, \u, and \U Unicode escape sequences
Escape or unescape XML special characters and numeric entities with one click
Escape or unescape SQL string literals using standard single-quote doubling
Convert text to HTML entities or decode HTML entities back to text in a single bidirectional tool
Wrap a raw string in a JSON string literal — perfect for embedding content in a JSON payload
Wrap an XML document in a JSON string literal for safe embedding in payloads
Encode or decode HTML entities
Encode text to HTML entities
Format and beautify JavaScript code online with clean indentation and proper spacing. Paste JS and get readable, formatted output for better code readability.
Minify JavaScript code by removing whitespace, comments, and shortening variable names. Reduce JS bundle size for faster page load and better Core Web Vitals.