JavaScript decodeURIComponent() Function
Example
Decode a URI after encoding it:
var uri = "http://subhodaya.com/my test.asp?name=ståle&car=saab";
var uri_enc = encodeURIComponent(uri);
var uri_dec = decodeURIComponent(uri_enc);
var res = uri_enc + "<br>" + uri_dec;
var uri_enc = encodeURIComponent(uri);
var uri_dec = decodeURIComponent(uri_enc);
var res = uri_enc + "<br>" + uri_dec;
The result of res will be:
// Encoded URI
http%3A%2F%2Fsubhodaya.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab
// Decoded URI
http://subhodaya.com/my test.asp?name=ståle&car=saab
Try it Yourself »
http%3A%2F%2Fsubhodaya.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab
// Decoded URI
http://subhodaya.com/my test.asp?name=ståle&car=saab
Definition and Usage
The decodeURIComponent() function decodes a URI component.
Tip: Use the encodeURIComponent() function to encode a URI component.
Browser Support
Function | |||||
---|---|---|---|---|---|
decodeURIComponent() | Yes | Yes | Yes | Yes | Yes |
Syntax
decodeURIComponent(uri)
Parameter Values
Parameter | Description |
---|---|
uri | Required. The URI to be decoded |
Technical Details
Return Value: | A String, representing the decoded URI |
---|
JavaScript Global Functions