URL Encoding Explained: Why You See %20 in Web Addresses
Ever copied a web address and found it full of strange things like %20 or %3D? That is URL encoding, also called percent encoding. It is how the web handles characters that are not allowed, or that have a special meaning, inside a link.
Why it is needed
A web address can only safely contain a limited set of characters. A space, an accent, an emoji, or symbols like & and = can break the link or change its meaning. So each unsafe character is replaced with a percent sign and two letters or digits. A space becomes %20.
A real example
Imagine a search link with the name "Asha & Ravi". If you put the & in plain, the server thinks a new parameter starts. Encoded, it becomes Asha%20%26%20Ravi and everything works.
encodeURI or encodeURIComponent?
encodeURIComponentencodes almost everything. Use it for one value, such as a search word.encodeURIkeeps characters like : / ? & = and #. Use it for a complete address.
Mixing them up is the most common mistake. If you use encodeURI on a single value that contains &, the problem stays.
The plus sign
In form data, a space is often written as +. In a normal address path it is %20. When decoding form data, convert plus to space first. Our tool does that for you.
Decoding errors
If you see "URI malformed", the text contains a % that is not followed by two valid characters. Usually the link was cut off, or someone typed a percent sign by hand.
Tips
- Encode each value separately, then join them with &.
- Do not encode twice, or %20 becomes %2520.
- Test links with unusual characters before sharing.
Try it
Use the URL Encode / Decode tool on our Developer Converters page. Paste your text, pick Encode or Decode, and tick "Whole URL" if you are working with a full link.
Frequently asked questions
Why do spaces become %20 in links?
Spaces are not allowed in web addresses, so they are written as their character code, 20 in hex, after a percent sign. In form data, a space may appear as + instead.
When should I use encodeURIComponent?
Use it for one piece of a URL, such as a search term or a parameter value, because it also encodes characters like &, = and / that would otherwise change the meaning of the address.
How do I decode a URL with %XX codes?
Use decodeURIComponent in JavaScript or our URL decoder. If it fails with "URI malformed", the text contains a % sign that is not followed by two hex digits.
Can Hindi or other non-English text be used in URLs?
Yes. The browser shows it normally, but behind the scenes each character is encoded as several %XX codes from its UTF-8 bytes. That is why copied links with Hindi words look very long.
Open the free Developer Converters. It runs in your browser, so nothing is uploaded.