Path: blob/main/files/en-us/web/javascript/reference/global_objects/decodeuricomponent/index.md
6520 views
------{{jsSidebar("Objects")}}
The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component previously created by {{jsxref("encodeURIComponent()")}} or by a similar routine.
{{EmbedInteractiveExample("pages/js/globalprops-decodeuricomponent.html")}}
Syntax
Parameters
encodedURI: An encoded component of a Uniform Resource Identifier.
Return value
A new string representing the decoded version of the given encoded Uniform Resource Identifier (URI) component.
Exceptions
{{jsxref("URIError")}}
: Thrown if
encodedURIcontains a%not followed by two hexadecimal digits, or if the escape sequence does not encode a valid UTF-8 character.
Description
decodeURIComponent() is a function property of the global object.
decodeURIComponent() uses the same decoding algorithm as described in {{jsxref("decodeURI()")}}. It decodes all escape sequences, including those that are not created by {{jsxref("encodeURIComponent")}}, like -.!~*'().
Examples
Decoding a Cyrillic URL component
Catching errors
Decoding query parameters from a URL
decodeURIComponent() cannot be used directly to parse query parameters from a URL. It needs a bit of preparation.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{jsxref("decodeURI")}}
{{jsxref("encodeURI")}}
{{jsxref("encodeURIComponent")}}