URL Encoder
Percent-encode and decode URLs, with a query-string breakdown.
About URL encoding
Percent-encoding escapes characters that would otherwise carry a special meaning in a
web address, replacing each byte with a % followed by two hex digits. A space
becomes %20, an ampersand %26, a question mark %3F.
Paste a full URL and you also get its parts broken out β scheme, host, port, path, fragment and every query parameter decoded β which is the fastest way to see what is actually being sent in a link.
Component vs full URL: the distinction that trips people up
The two modes are not interchangeable, and picking the wrong one is the most common URL encoding bug.
Component encoding escapes the structural characters
& = ? / : as well. Use it for a single value you are putting
inside a query string. If a search term contains an ampersand and you don't
escape it, the server reads it as the start of a new parameter and your value is silently
truncated.
Full URL encoding leaves those structural characters alone so the address stays valid. Use it when you have a whole URL containing spaces or accented characters and you want to make it safe without destroying its structure.
Frequently asked questions
What is %20 in a URL?
It is a space. Spaces are not allowed in URLs, so they are percent-encoded as %20. You may also see + used for a space, which is a legacy convention specific to form data in query strings.
When should I use encodeURIComponent instead of encodeURI?
Use component encoding for a single value going inside a query string, because it also escapes &, = and ?. Use full-URL encoding for a complete address, because it leaves the structural characters intact.
Why is my query parameter being cut off?
Almost certainly because the value contains an unescaped & or #, so the server treats it as the start of the next parameter or the fragment. Encode the value with the component mode before adding it to the URL.
Do I need to encode non-English characters in a URL?
Modern browsers display them correctly and often handle the conversion for you, but the URL sent over the wire is percent-encoded UTF-8. Encode explicitly when building links programmatically to avoid inconsistencies.