How to Decode URI components in Javascript

You can decode URI components in Javascript using the decodeURIComponent() function. It performs the inverse operation of encodeURIComponent(). It uses UTF-8 encoding scheme to decode URI components.

Javascript URL decoding using the decodeURIComponent() function

The decodeURIComponent() function converts a URL encoded string back to its normal form. The following example demonstrates how to decode URI components in Javascript -

var query = "Hellö Wörld";
var queryEnc = encodeURIComponent(query);
var queryDec = decodeURIComponent(queryEnc);

console.log("Encoded Query: " + queryEnc)
console.log("Decoded Query: " + queryDec)
# Output
Encoded Query: Hell%C3%B6%20W%C3%B6rld
Decoded Query: Hellö Wörld

Also Read: URL Encoding a String in Javascript