Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
encodeURI() if possible.
escape() function computes a new string in which certain characters have been replaced by hexadecimal escape sequences.
A string to be encoded.
A new string in which certain characters have been escaped.
escape() is a function property of the global object.
escape() function replaces all characters with escape sequences, with the exception of ASCII word characters (A–Z, a–z, 0–9, _) and
@*_+-./. Characters are escaped by UTF-16 code units. If the code unit's value is less than 256, it is represented by a two-digit hexadecimal number in the format
%XX, left-padded with 0 if necessary. Otherwise, it is represented by a four-digit hexadecimal number in the format
%uXXXX, left-padded with 0 if necessary.
escape("abc123"); // "abc123" escape("äöü"); // "%E4%F6%FC" escape("ć"); // "%u0107" // special characters escape("@*_+-./"); // "@*_+-./"
|ECMAScript Language Specification |
BCD tables only load in the browser