decodeURIComponent()

Decodes a URI component previously encoded with encodeURIComponent().

Since ES3 Spec ↗

Syntax

decodeURIComponent(encodedStr)

Returns

string — The decoded string.

Throws

  • URIError — The input contains a malformed percent-escape sequence.

Examples

console.log(decodeURIComponent("a%20b%26c%3Dd"));
Output
a b&c=d
console.log(decodeURIComponent("caf%C3%A9"));
Output
café

Notes

- Inverse of `encodeURIComponent()`. - Throws `URIError` on invalid sequences like `"%"` or `"%E0%A4"`.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also