URL Encoder / Decoder
Encode or decode URLs and query string parameters.
URL Encoding Explained
URL encoding (also called percent-encoding) replaces unsafe characters with a percent sign followed by two hexadecimal digits that represent the character's UTF-8 byte. Reserved characters that have a special meaning in URLs — such as / ? # & = + space — must be percent-encoded when they appear inside a path segment or a parameter value rather than as a delimiter.
JavaScript exposes two built-in helpers. encodeURIComponent encodes everything except A–Z, a–z, 0–9, and the unreserved characters - _ . ! ~ * ' ( ). It is the right choice for a single query parameter value because it preserves no URL structure. encodeURI is more permissive: it leaves URI-structural characters such as : / ? # & untouched, so it is appropriate for whole URLs that already contain valid structure.
This tool wraps both functions and handles failure gracefully. If you paste a malformed percent sequence (for example a stray %Z), the decoder returns an explanatory error rather than throwing. Non-ASCII characters such as Chinese, Japanese, or emoji are first converted to UTF-8 bytes before encoding, which is the modern standard adopted by every major browser.
Use cases
- Build query strings that include spaces, symbols, or non-ASCII characters.
- Decode a logged URL to see what a user actually submitted.
- Safely pass a redirect target as a query parameter.
- Debug issues where servers receive unexpected characters.
- Generate clean OAuth callback URLs that include a state parameter.
Best practices
- Use encodeURIComponent for individual parameter values, not for entire URLs.
- Encode space as %20 in URL paths; only application/x-www-form-urlencoded bodies use + for space.
- Encode user-controlled values before concatenating them into a URL to prevent injection.
- Remember that the # fragment is never sent to the server, so credentials should not live there even encoded.