URL Encoder / Decoder
Encode special characters for use in URLs, or decode percent-encoded strings back to plain text.
About the URL Encoder / Decoder
URLs can only contain a limited set of ASCII characters. Spaces, accented letters, and symbols like &, =, #, and ? must be percent-encoded before use in a URL. Percent-encoding replaces each unsafe character with a % followed by its two-digit hexadecimal ASCII value: a space becomes %20, an ampersand becomes %26, and a hash becomes %23.
When do you need URL encoding?
- Query parameters — values containing = or & must be encoded so they do not break the URL structure.
- File paths with spaces — "my document.pdf" must become "my%20document.pdf".
- API requests — parameters in REST API calls must be encoded to avoid server parsing errors.
- Unicode characters — non-ASCII characters must be UTF-8 encoded then percent-encoded.
encodeURI vs encodeURIComponent
In JavaScript, encodeURI encodes a full URL and leaves structural characters (/, ?, &, =) untouched. encodeURIComponent encodes everything including those characters, making it correct for encoding individual parameter values. Use encodeURIComponent for query string values.
URL encoding edge cases
Most URL encoding issues in practice come from edge cases: encoding the full URL when you should only encode parameter values (which breaks the URL structure), double-encoding (encoding an already-encoded string, turning %20 into %2520), and not encoding when submitting forms via JavaScript fetch where URLSearchParams handles encoding automatically.
- Double-encoding — encoding an already-encoded string: %20 becomes %2520; check for this when debugging 404 errors
- Form submission — HTML forms encode data automatically; when using fetch() with URLSearchParams, encoding is also automatic
- Path vs query — encode path segments and query values separately; they have different allowed character sets
- IDN (Internationalised Domain Names) — non-ASCII domain names use Punycode, not percent-encoding: "münchen.de" → "xn--mnchen-3ya.de"
Frequently Asked Questions
encodeURIComponent("your text"). Python: from urllib.parse import quote; quote("your text"). PHP: urlencode("your text"). The encoded result replaces each special character with its %XX hex equivalent.