What URL encoding is
A URL can only contain a limited set of characters. Letters, digits and a few symbols are safe everywhere, while spaces, accented letters and characters such as &, = and ? either have a special job in the URL or are not allowed at all. Percent-encoding, also called URL encoding, replaces each unsafe byte with a percent sign followed by two hexadecimal digits. A space becomes %20, a slash becomes %2F and the percent sign itself becomes %25.
How non-ASCII text is encoded
Text is first converted to UTF-8 bytes, and each byte is then percent-encoded. The letter é is two bytes, C3 and A9, so it becomes %C3%A9. The euro sign is three bytes and becomes %E2%82%AC. Decoding reverses the steps, joining the bytes back into characters.
Component versus full URL
| Mode | Leaves alone | Use it for |
|---|---|---|
| Component | A-Z a-z 0-9 - _ . ! ~ * ' ( ) | A single query value, path segment or form field |
| Full URL | The above plus ; , / ? : @ & = + $ # | A complete address whose structure must stay intact |
The difference matters. If you encode a whole URL as a component, the slashes and question mark are escaped and the link breaks. If you encode a query value in full URL mode instead, an ampersand inside the value is left alone and is read as a separator. This tool uses component mode, the safe choice for values.
Worked example
Encoding the value name=Zoë & co/100% as a component gives name%3DZo%C3%AB%20%26%20co%2F100%25. Likewise a b&c=d/é becomes a%20b%26c%3Dd%2F%C3%A9. This tool always encodes in component mode, so to keep a whole address working, encode only the parts that hold data, such as each query value, and leave the scheme, slashes, question mark, ampersands and hash as they are.
Reserved and unreserved characters
RFC 3986 calls letters, digits, hyphen, period, underscore and tilde unreserved: they never need encoding. The reserved characters : / ? # [ ] @ ! $ & ' ( ) * + , ; = have special meaning and must be encoded when they appear as data rather than as syntax. The standard JavaScript functions are slightly more relaxed than the RFC and leave a few extra characters, such as ! * ' ( ), unescaped in component mode.
Plus signs and spaces
Within the query string of an HTML form submission, spaces are traditionally written as +. Percent-encoding proper uses %20. This tool keeps plus signs as they are when decoding, since a literal plus is common in phone numbers and time zone offsets. To decode form data, replace each + with a space first.
Common problems
- Double encoding: encoding text that is already encoded turns %20 into %2520. Decode first if you see this.
- Malformed sequences: a stray percent sign not followed by two hex digits cannot be decoded.
- Wrong charset: old systems may use Latin-1 instead of UTF-8, which produces different byte sequences for accented letters.
Everything on this page runs in your browser. Your text is never uploaded.
Where you will meet encoded URLs
Percent-encoding shows up in query strings from search engines and forms, in redirect addresses that carry another URL as a parameter, in file names with spaces or accents, and in links shared by email and chat. When a link looks like a wall of percent signs, decoding it reveals the real text. When you build a link by hand, such as a mailto link with a subject line or a redirect to a login page, encode each value as a component first and then join them with the real ampersands and equals signs.
Characters worth remembering
| Character | Encoded |
|---|---|
| Space | %20 |
| & | %26 |
| = | %3D |
| ? | %3F |
| # | %23 |
| / | %2F |
| % | %25 |