Free JavaScript escape & unescape tool — quotes, backslashes, newlines for JS string literals

Escaping runs entirely in your browser — nothing is uploaded.

🟨 JavaScript Escape / Unescape — Free Online Tool

Escape and unescape JavaScript strings online, free. JavaScript string escaping makes text safe to drop into any JS string literal — single-quoted, double-quoted, or a template literal — by escaping the backslash, the quote characters, and whitespace controls. This tool escapes text for source code or reverses it, entirely in your browser.

🚀 Why use this JavaScript Escape / Unescape tool?

It escapes all three quote styles (' " `) plus ${ and the backslash, so the result is valid in any JavaScript string literal. 100% free, no registration, and complete privacy — everything runs locally in your browser, so your data never touches a server.

Key Features

🧬All quote styles

Escapes ', " and the backtick ` (plus ${ in template literals) so the string is safe in any context.

🔁Escape & unescape

Turn raw text into a JS string literal body, or decode \n, \', \\ back to characters.

Instant & in-browser

Runs locally with no upload — safe for config and keys you paste into source.

🔒100% private

Your code and strings never leave your device.

Popular Use Cases

Embedding in code

  • Paste text into a JS string
  • Escape quotes in source
  • Build template-literal content

Debugging

  • Decode an escaped string
  • Read \uXXXX / \n sequences
  • Fix a broken literal

Config & data

  • Embed JSON-ish strings
  • Encode messages for source
  • Prepare test fixtures

What It Handles

Modes

  • Escape (text → JS literal)
  • Unescape (JS literal → text)

Handles

  • \\ ' " `
  • ${ in templates
  • \n \r \t

Privacy

  • Client-side only
  • No network calls
  • Runs offline

Sources & References

Frequently Asked Questions

How do I escape a quote in a JavaScript string?

Inside a single-quoted string escape ' as \'; inside a double-quoted string escape " as \"; inside a template literal escape the backtick ` as \` and ${ as \${. This tool escapes all quote styles plus the backslash so the result is safe in any JS string literal.

What characters does JavaScript string escaping cover?

The backslash itself (\\), the three quote characters (' " `), and the whitespace controls newline (\n), carriage return (\r) and tab (\t). Backslash must be escaped first, otherwise it would corrupt the following escape sequences.

Is JavaScript escaping the same as JSON escaping?

They overlap but differ. JSON only allows double-quoted strings and a fixed set of escapes; JavaScript also has single quotes, template-literal backticks and ${} interpolation. Use JavaScript Escape for code you paste into a .js file, and JSON Escape for values going into a .json document.

Does this run on a server?

No. Escaping and unescaping happen entirely in your browser with plain JavaScript — no upload, no logging. Safe for embedding API keys or config strings into source.

Can I unescape a JavaScript string back to plain text?

Yes. Click Unescape and the tool reverses the literal escapes — \n becomes a real newline, \' becomes ', and \\ becomes a single backslash — recovering the original text.

🎓 Pro Tips

  • Tip 1: Escape the backslash first — it must be doubled before other sequences, or it will corrupt the following escape.
  • Tip 2: Use JavaScript Escape for .js source and JSON Escape for .json values; template-literal backticks and ${} are JS-only.
  • Tip 3: Prefer template literals for multi-line strings so you don't have to escape every newline as \n.