Favorites

JavaScript decodeURIComponent() Function

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
decodeURIComponent()
JavaScript Global functionThis function is supported by all modern browsers.
Updated 28th November 2026

The decodeURIComponent() function decodes text that was percent-encoded for use in a URL.

Description

The decodeURIComponent() function reverses encodeURIComponent(), turning percent-encoded sequences such as %20 back into characters. Malformed sequences throw a URIError, so wrap it in try...catch for values from users or URLs. Note that it doesn't turn + into a space; URLSearchParams does.

It decodes every escape sequence, including those for characters such as /, ? and &, so only decode individual values after splitting the URL into its parts. Decoding a whole URL first and then splitting it can break when a value contains an encoded & or =.

For query strings, new URLSearchParams(location.search).get('q') handles splitting, + signs and decoding for you, and for URLs in general the URL object provides decoded parts.

Syntax

decodeURIComponent(encodedString)

Parameters

  • encodedStringA string that was encoded with encodeURIComponent().

Return Value

The decoded string.

Exceptions

  • URIErrorThrown if the string contains invalid percent-encoding.

Example

console.log(decodeURIComponent('cats%20%26%20dogs'));
console.log(decodeURIComponent('caf%C3%A9'));
try { decodeURIComponent('%'); } catch (e) { console.log(e.name); }

Browser Support

The following information will show you the current browser support for the decodeURIComponent() function. Hover over a browser icon to see the version that first introduced support for this function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee