URL encoding (encode / decode)
Converts text to percent-encoding and back: accented letters and spaces become "%C3%A9" and "%20". Three sets: part of an address, full address, form field.
Input
Report a problem
What percent-encoding is
What it is for
An address can consist only of a small set of ASCII characters. Everything else – accented letters, spaces, quotes, emoji – is passed as a sequence of "%" and two hexadecimal digits for each byte. So café in an address looks like caf%C3%A9: the three plain letters stay, and é takes two bytes.
Three sets, not one
Part of an address escapes everything except letters, digits and -._~. This is the set for one value: when a parameter contains /, & or ?, they have to become escapes, otherwise they break the address they are inserted into.
Full address leaves in place the characters that hold a link together: :, /, ?, #, &, =. It is used to fix a ready link that has spaces or accented letters. You cannot encode a value inside it with this set – it leaves the separators untouched.
Form field is the rule a browser uses to send a form: a space becomes +. Outside the query string + means an ordinary plus, which is why this set is a separate option and is not guessed from the text.
The reverse direction
Decoding reads each %XX sequence as a byte and builds text from the bytes. If the string has a % not followed by two hexadecimal characters, there is nothing to decode – it is just text with a percent sign, and the page says so directly instead of dropping the character silently.
Frequently asked questions about URL encoding
Why does one letter give two escapes?
Because in UTF-8 an accented letter is written with two bytes, and an escape describes one byte. é is %C3%A9. A plain Latin letter takes one byte and needs no escaping at all.
Is a space %20 or +?
%20 in an address, + in a form field. Both read as a space where they belong, but + in a path stays a plus.
Can I put accented letters straight into an address?
The browser shows them readably, but still sends them encoded. The problem starts when the link is copied: in an email or a message it expands into a long string of percent signs.
I decoded it and got garbled characters
The text was not encoded in UTF-8 – most often in windows-1252. The page does not guess the encoding: it says the bytes do not read as UTF-8, and stops.
How many times can you encode?
As many as you like, and each time % becomes %25. Double encoding is a common reason a link does not open: decode twice and you will see what is inside.