URL encoding without the headaches
This short guide explains what the url encoder decoder does, how to get the best result and when another tool is a better fit.
Why URLs need encoding
A URL uses some characters for structure: ? starts the query, & separates parameters and = links a name to its value. If a value itself contains one of these characters, such as a search for ‘fish & chips’, the URL breaks. Percent-encoding replaces those characters with safe codes, so ‘fish & chips’ becomes ‘fish%20%26%20chips’ and arrives intact.
Spaces, accents and non-Latin letters also need encoding, because URLs officially allow only a small set of ASCII characters.
Encode the value, not the whole URL
This tool uses the same method as JavaScript’s encodeURIComponent, which encodes everything except letters, numbers and - _ . ! ~ * ' ( ). That is exactly right for one parameter value, but if you paste a whole URL, the :// and slashes are encoded too and the link stops working. Build the URL first, then encode only the values that go after the = signs.
Decoding is safe for whole URLs and turns %20, %26 and friends back into readable text.
A worked example
A marketer wants a tracking link with the campaign name ‘Summer Sale – 20% off’. Pasting the raw name into the URL breaks it at the % sign. Encoding just the name gives ‘Summer%20Sale%20%E2%80%93%2020%25%20off’, which goes after utm_campaign=. Analytics then shows the campaign name exactly as typed.
Decoding a long, messy link someone sent you is the reverse: paste it in and see where it really goes.
Reserved and unreserved characters
The URL standard splits characters into two groups. Unreserved characters, which are letters, digits and - . _ ~, never need encoding. Reserved characters such as : / ? # [ ] @ ! $ & ' ( ) * + , ; = have special meanings in a URL and must be encoded when they appear inside a value. Everything else, including spaces and non-ASCII letters, must always be encoded.
Most modern browsers show decoded, readable URLs in the address bar even when the real link is encoded, which is why copying a link sometimes gives you a long string of %xx codes.
Errors and special cases
Decoding fails with a ‘URI malformed’ message when a % sign isn’t followed by two valid hexadecimal digits, for example in text that contains ‘100%’ on its own. Some forms encode spaces as + instead of %20; this tool doesn’t turn + into a space, so replace those first if needed.
- Encode values, not whole URLs
- Decode whole links to read them
- Replace + with spaces for form data
Further reading: RFC 3986, the URL syntax standard. It explains the format behind this url encoder decoder in more detail.
