decodeURIComponent Function

decodeURIComponent Function (JavaScript)


Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).


The required encodedURIString argument is a value representing an encoded URI component.

A URIComponent is part of a complete URI.

If the encodedURIString is not valid, a URIError occurs.

The following code first encodes and then decodes a URI.

var uriEncode = encodeURI ("http://www.Not a");
var uriDecode = decodeURIComponent(uriEncode);

document.write (uriEncode);
document.write (uriDecode);

// Output:
// http://www.Not a


Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

© 2015 Microsoft