Limited supportAvoid in new code. Keep only when maintaining or migrating legacy behavior.

Overview

escape() and unescape() are legacy string encoding helpers from older JavaScript environments. Modern URL and text encoding should use dedicated APIs such as encodeURIComponent instead.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
escape
Deprecated
1
12
1
1
18
1
Other

The unescape() function computes a new string in which hexadecimal escape sequences are replaced with the characters that they represent. The escape sequences might be introduced by a function like escape().

1
12
1
1
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
// escape() and unescape() example
// See MDN Web Docs for details

Live demo

Encode with escape and encodeURIComponent

Compare the legacy functions with modern URL-safe encoding.

JavaScript
Output
Press the Run button

Decode encoded text

Restore the original string from an escaped sequence.

JavaScript
Output
Press the Run button

Handle non-ASCII characters

See why escape/unescape are legacy APIs for Unicode text.

JavaScript
Output
Press the Run button

Use cases

  • Legacy compatibility review

    Identify and replace older encoding helpers when updating historical codebases.

  • Understanding old scripts

    Recognize what escape and unescape are doing when reading older browser-oriented code.

Cautions

  • These functions do not match modern URL-encoding expectations and often produce confusing behavior.
  • Replace them with explicit, standards-based encoding functions whenever possible.

Accessibility

  • Incorrect encoding can break user-visible text, links, or labels in ways that affect accessibility.
  • Use modern encoding APIs to keep content predictable across languages and assistive tools.

Powered by web-features