JavaScript (ES2026) reference · JSON and Global Functions

JavaScript decodeURIComponent() Function

Decode a URL component encoded by encodeURIComponent(), turning %20-style escapes back into characters.

JavaScript (ES2026) Since ES3

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

decodeURIComponent(encoded)

Parameters

ParameterDescription
encoded An encoded string.

Return value

A decoded string.

Examples

Decode a valueTry it yourself
console.log(decodeURIComponent("tea%20%26%20cake%3F"));

Output

tea & cake?
Malformed input throws URIErrorTry it yourself
try {
  decodeURIComponent("%E0%A4%A");
} catch (e) {
  console.log(e.name);
}

Output

URIError

Version history

VersionChange
JavaScript ES3Added

Was this page helpful?