JavaScript decodeURIComponent() Function
JavaScript Global Functions
Definition and Usage
The decodeURIComponent() function decodes a URI encoded by the encodeURIComponent() function.
**Tip:** Use encodeURIComponent() The method can be used to encode a URI.
Syntax
decodeURIComponent(uri)
| Parameters | 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
Example
Example
Use decodeURIComponent() to decode an encoded URI:
var
uri
=
"
https://www.runoob.com/my test.php?name=ståle&car=saab
"
;
var
uri_encode
=
encodeURIComponent
(
uri
)
;
document
.
write
(
uri_encode
)
;
document
.
write
(
"
"
)
;
document
.
write
(
decodeURIComponent
(
uri_encode
)
)
;
The output of the above example is:
https%3A%2F%2Fwww.runoob.com%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab
https://www.runoob.com/my test.php?name=ståle&car=saab
Try it »
JavaScript Global Functions