URL Encoder/Decoder
Free online URL encoder and decoder (percent-encoding). Handle query strings and non-ASCII characters correctly.
URL Encoder/Decoder guide
Why URLs can’t contain just anything
URLs were designed around a small safe alphabet. Characters like space, &, =, ?, # and non-ASCII letters carry structural meaning or simply aren’t allowed in transmission — so they get percent-encoded: each byte becomes %XY. A Chinese character in UTF-8 is 3 bytes, hence %E4%B8%AD for 中. That is why Chinese URLs look “ugly” when encoded and long when pasted.
encodeURIComponent vs encodeURI — the eternal confusion
encodeURI escapes a complete URL while preserving its structure (/:?#& stay intact). encodeURIComponent escapes everything, designed for individual values you insert INTO a URL — a query parameter containing & must have it escaped or it breaks the query string. The rule: encode the whole URL with encodeURI, encode each value with encodeURIComponent. Using the wrong one is the source of most “my ampersand ate the rest of the parameters” bugs.
- Space: %20 in paths (standard); + means space only in application/x-www-form-urlencoded form data.
- Never encode an entire URL twice — %2520 is a double-encoded space and will not decode back correctly.
- When decoding unknown input, decodeURIComponent is almost always what you want for parameter values.
Debugging real-world cases
A share link that truncates at the first Chinese character: the app built the URL without encoding. A search box where multi-word queries return wrong results: & inside the query wasn’t escaped. A JWT in a URL failing validation: base64url padding characters (+ and /) need the URL-safe variant. Each of these is a percent-encoding diagnosis — paste the failing URL here, decode, and look at what was actually being passed.