CKTIS / JavaScript
decodeURIComponent — decode a URI component
decodeURIComponent decodes percent escapes in an individual URI component, interpreting encoded bytes as UTF-8. It returns text, leaves + unchanged, and throws URIError for malformed encoding.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
decodeURIComponent(encodedURIComponent)decodeURIComponent(encodedURIComponent) is a global ECMAScript function for decoding an individual URI component. It first converts its argument to a string, then replaces %HH escapes with the corresponding characters, interpreting encoded bytes as UTF-8. It returns a string without modifying the argument.
Unlike decodeURI, it also decodes escaped reserved characters such as %26, %2F, and %3D. Separate an address into components before decoding their values: decoding earlier can turn data into delimiters. A literal + remains unchanged; the function does not treat it as a space.
Incomplete percent escapes, invalid hexadecimal digits, or invalid UTF-8 cause URIError. Handle this exception for external input. Decode according to the expected number of encoding layers: %252F becomes %2F after one call and / after a second.
The example demonstrates decoding Unicode text and reserved characters, preserving +, and handling malformed input. This is an ECMAScript language function, not an API that requires a browser environment.
Examples
const encoded = "caf%C3%A9%20%26%20tea%2Bcake";
console.log(decodeURIComponent(encoded));
console.log(decodeURIComponent("a+b"));
try {
decodeURIComponent("%E0%A4%A");
} catch (error) {
console.log(error.name);
}Result
café & tea+cake a+b URIError
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.