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
Syntax
decodeURIComponent(encoded)
Parameters
| Parameter | Description |
|---|---|
encoded |
An encoded string. |
Return value
A decoded string.
Examples
console.log(decodeURIComponent("tea%20%26%20cake%3F"));
Output
tea & cake?
try {
decodeURIComponent("%E0%A4%A");
} catch (e) {
console.log(e.name);
}
Output
URIError
Version history
| Version | Change |
|---|---|
| JavaScript ES3 | Added |
Related
encodeURIComponent()· Encode a string for use as one part of a URL (a query value or path segment), escaping &, =, ?, / and spaces.decodeURI()· Decode a full URL encoded by encodeURI(), keeping escape sequences that represent reserved URL characters.- JavaScript Fetch API · tutorial