Skip to content
Created by Iternal Technologies, the AI Strategy ExpertsBy Iternal (opens in a new tab)

Escape & Encode

JavaScript Escape

Text

Paste or type anything. Quotes, line breaks and controls become JavaScript string escapes as you type.

JavaScript string

About JavaScript Escape

JavaScript Escape turns text into the body of a JavaScript string literal. Quotes, backslashes, line breaks, tabs and other controls become source escapes such as \n and \u00XX. It writes a string literal, not the legacy escape() function.

With neither wrap option both quote marks are escaped, so the text can sit inside single or double quotes. Wrap in double quotes or Wrap in single quotes adds that pair; if both are on, double quotes win. Escape non-ASCII writes every code unit above U+007F as \uXXXX, and an emoji becomes two escapes. Line and paragraph separators are always \u2028 and \u2029. A null before a digit is written as \u0000 so the literal stays valid in strict mode.

Escaping runs in your browser and the text you paste is never uploaded. Swap sends the result to JavaScript Unescape so you can check the round trip.

Frequently asked questions

What does escaping text for JavaScript do?

It rewrites characters that would break a JavaScript string literal. Backslashes, line breaks, tabs and control characters become source escapes, and quote marks are escaped so the text can sit inside quotes. With the default settings the output has no surrounding quotes.

Is this the JavaScript escape() function?

No. This writes a JavaScript string literal, the text between quotes in source code. It is not the legacy escape() function, which percent-encodes a string and is deprecated.

When should I wrap the output in quotes?

Turn on Wrap in double quotes or Wrap in single quotes when you want a complete literal to paste into code. If both are on, the output uses double quotes. With neither option, both quote marks are escaped and no quotes are added around the text.

What does Escape non-ASCII change?

Each UTF-16 code unit above U+007F is written as \uXXXX. An emoji, which is two units, becomes two escapes. A JavaScript engine reads those escapes back as the same text.

Is the text I paste uploaded anywhere?

No. Escaping runs in your browser and the text you paste is never uploaded, logged or stored. Google Analytics records page views and feature use, never content.

Iternal · AI Blueprint Builder

Plan the AI initiative, not just the output

The AI Blueprint Builder scores each use case across value, feasibility, cost, governance, risk, adoption and readiness before you commit budget. Free to start, about 60 minutes.

Open the AI Blueprint Builder (opens in a new tab)