JavaScript decodeURIComponent()Function
JavaScript Global Functions
Definition and Usage
The decodeURIComponent() function decodes a URI that was encoded by the encodeURIComponent() function.
Tip:UseencodeURIComponent()method can encode a URI.
Syntax
decodeURIComponent(uri)
| Parameter | Description |
|---|---|
| uri | Required. A string containing an encoded URI component or other text to be decoded. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the decodeURIComponent() function.
Examples
Example
Use decodeURIComponent() to decode an encoded URI:
var uri="https://www.example.com/my test.php?name=ståle&car=saab";
var uri_encode=encodeURIComponent(uri);
document.write(uri_encode);
document.write("<br>");
document.write(decodeURIComponent(uri_encode));
The above example outputs:
https%3A%2F%2Fwww.example.com%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab https://www.example.com/my test.php?name=ståle&car=saab
Try it Yourself »
JavaScript Global Functions Other Extensions