Copy a link with a space or an accented letter in it and you might get something like my%20file%20caf%C3%A9.pdf. It looks broken, but it is exactly how the web is designed to work. So what is URL encoding, why is it needed, and how do you encode or decode links correctly? Here is a practical explanation for marketers, developers and curious users.
The short answer
URL encoding – officially called percent-encoding – replaces characters that are not allowed or have special meaning in a URL with a % sign followed by two hexadecimal digits representing the character's byte value.
- Space →
%20 - & →
%26 - ? →
%3F -
→
%23 - / →
%2F - = →
%3D
Why URLs need it
URLs can only contain a limited set of characters: letters, digits and a few symbols such as -, _, . and ~. Other characters are either unsafe (spaces, quotes) or reserved because they have a job:
?starts the query string&separates parameters=separates a name from its value#starts the fragment (an anchor on the page)/separates path segments
If a search term or product name contains one of these special characters, it must be encoded, or the browser will misread the address. A search for "fish & chips" must be sent as q=fish%20%26%20chips; otherwise "chips" would look like a separate parameter.
Non-English characters
Characters outside basic ASCII are first converted to UTF-8 bytes, then each byte is percent-encoded:
- é →
%C3%A9 - ₦ →
%E2%82%A6
Browsers often display the friendly version in the address bar while sending the encoded version behind the scenes. Read what is ASCII for how characters become numbers.
%20 or +?
In the path of a URL, a space is always %20. In query strings submitted by HTML forms, spaces are often written as +. Both decode to a space in the right context, but mixing them up can break links – when in doubt, use %20.
Encoding in code
- JavaScript:
encodeURIComponent('fish & chips')→fish%20%26%20chips. Use it for individual parameter values.encodeURI()is for whole URLs and leaves reserved characters alone. - PHP:
rawurlencode()(uses %20) orurlencode()(uses +). - Python:
urllib.parse.quote().
Common problems
- Double encoding:
%20becomes%2520when something encodes an already-encoded URL. Decode once to check. - Tracking links breaking: UTM parameters with spaces or & need encoding.
- Ugly shared links: use hyphenated slugs instead of spaces in page addresses – see what is a URL slug.
Encode and decode instantly
The free URL Encode and Decode tool converts text to percent-encoding and back, handling UTF-8 correctly. To inspect a full address, use the URL Parser, which splits it into protocol, domain, path and decoded query parameters – see the parts of a URL.
Related tools: Base64 Encode and Decode and the HTML Entity Encoder for text inside web pages.
Frequently asked questions
Is URL encoding a security feature? No. It only makes characters safe to transmit. Anyone can decode it.
Do I need to encode letters and numbers? No. Unreserved characters – A–Z, a–z, 0–9, hyphen, underscore, full stop and tilde – never need encoding.
Why does my link show %E2%80%99? That is a curly apostrophe (’) copied from a word processor. Replace it with a straight one or avoid apostrophes in URLs.
Should page addresses contain encoded characters at all? Ideally not. Choose simple slugs with letters, numbers and hyphens so links stay readable when people share them on WhatsApp, email and social media.
Summary
So, what is URL encoding? A system that replaces unsafe and reserved characters in web addresses with % codes, such as %20 for a space, so links work everywhere. Encode individual parameter values, avoid double encoding and keep page URLs simple. Convert anything instantly with the free URL Encode and Decode tool.