URL Decoder
Convert percent-encoded strings back to their original readable form. URL decoding transforms %XX codes into their corresponding characters.
How URL Decoding Works
| Encoded | Decoded | Description |
|---|---|---|
| %20 | (space) | Space character |
| %26 | & | Ampersand |
| %3D | = | Equals sign |
| %2F | / | Forward slash |
| %3F | ? | Question mark |
| %25 | % | Percent sign |
URL Decode Implementation
``javascript
// Built-in JavaScript decoding
function urlDecode(encodedString) {
try {
return decodeURIComponent(encodedString);
} catch (error) {
return decodeURIComponent(
encodedString.replace(/%(?![0-9A-Fa-f]{2})/g, '%25')
);
}
}
// Handle + as space (common in query strings)
function urlDecodeWithPlus(encodedString) {
return decodeURIComponent(encodedString.replace(/\+/g, ' '));
}
// Examples
urlDecode('Hello%20World'); // "Hello World"
urlDecode('%E4%B8%AD%E6%96%87'); // "δΈζ"
`
Decoding Different URL Parts
`javascript
// Parse and decode full URL
function parseEncodedUrl(url) {
const parsed = new URL(url);
return {
pathname: decodeURIComponent(parsed.pathname),
params: Object.fromEntries(parsed.searchParams)
};
}
``
Use this decoder to make URL-encoded strings readable.