Which characters get a percent sign
A URL may only contain a small set of characters as they are: the letters A–Z and a–z, the digits 0–9 and the four marks - _ . ~. Everything else is written as a % sign followed by two hex digits for each UTF-8 byte. Some characters have a job inside a URL, such as / between folders, ? before the query, & between parameters and = between a name and a value. They must be encoded whenever they are part of a value rather than doing that job.
space → %20
& → %26
= → %3D
/ → %2F
café → caf%C3%A9
ঢাকা → %E0%A6%A2%E0%A6%BE%E0%A6%95%E0%A6%BE
A non-English letter becomes two or three encoded bytes, which is why a Bangla or Arabic link turns so long when you copy it out of the address bar.
Encode Component or Encode Full URL
The two buttons follow the JavaScript functions encodeURIComponent and encodeURI. Typing in the input box runs Encode Component on the fly.
- Encode Component escapes everything except letters, digits and - _ . ! ~ * ' ( ). Use it for one piece of a URL: a search term, a parameter value, or a whole URL passed as a value, such as ?redirect=https%3A%2F%2Fexample.com%2Fcart.
- Encode Full URL leaves : / ? # & = + $ , ; @ alone and only escapes spaces, non-English letters and other characters that can never appear in a URL. Use it to tidy a complete address that someone typed with spaces in it.
Running Encode Component on a whole address breaks it, because https:// becomes https%3A%2F%2F and the browser no longer sees a link. Running Encode Full URL on a value is the opposite mistake: an & inside the value stays as it is and splits the parameter in two.
Plus signs, %2520 and decoding errors
HTML forms send spaces as + instead of %20. The decoder treats + as a real plus sign, as the URL standard says, so a query copied from a form submission such as q=red+shoes decodes to “red+shoes”. Replace the plus signs with spaces first if the text came from a form.
If you see %2520 in a link, the text was encoded twice: the % of %20 was itself turned into %25. Decode once and check whether the result still has %20 in it; if it does, the original was double encoded and should be fixed where the link is built.
Decoding fails with an error when a % is not followed by two hex digits, as in “100% cotton”, or when the bytes do not form valid UTF-8. Encode such text rather than decoding it.
Encoding inside code
Most languages have a built-in function, and it is safer to call it than to paste in encoded strings by hand:
- JavaScript: encodeURIComponent(value), or new URLSearchParams({ q: value }).toString() for a whole query string.
- PHP: rawurlencode($value) gives %20 for spaces; urlencode($value) gives + like a form; http_build_query($array) builds a full query string.
- Python: urllib.parse.quote(value, safe='') for a component and urllib.parse.urlencode(dict) for a query string.
The converter is handy for checking what those functions produce, for reading an encoded link from a log, or for building a one-off link by hand. Everything runs in your browser, so nothing you paste is sent anywhere.