Why URLs need encoding
URLs may only contain a limited set of characters: letters, digits and a few symbols. Some symbols have a job: ? starts the query string, & separates parameters, = joins a name to its value and # starts the fragment. If your data contains those characters (or spaces, or non-English letters), they must be encoded, or the URL will be read wrongly.
How percent-encoding works
Each character is converted to its UTF-8 bytes, and each byte is written as % plus two hex digits. Characters outside English take more than one byte:
| Character | Encoded |
|---|---|
| space | %20 (or + in form data) |
| & | %26 |
| / | %2F |
| ? | %3F |
| # | %23 |
| % | %25 |
| é | %C3%A9 |
| € | %E2%82%AC |
encodeURIComponent or encodeURI?
- encodeURIComponent encodes everything except letters, digits and
- _ . ! ~ * ' ( ). Use it for a piece of a URL: a query value, a path segment, a filename. This is almost always the one you want. - encodeURI leaves URL structure characters (
: / ? & = #) alone. Use it only to clean up a complete URL that contains spaces or accents. - Form encoding (application/x-www-form-urlencoded) is like encodeURIComponent but writes spaces as
+. HTML forms send data this way, and PHP'surlencodedoes the same.
Common problems
- Double encoding: encoding text that's already encoded turns
%20into%2520. If you see%25followed by two hex digits, decode twice. - Plus signs: in query strings from forms,
+means a space. A real plus sign must be sent as%2B. - "URI malformed" errors: a lone
%that isn't followed by two hex digits can't be decoded. Encode literal percent signs as%25.
Breaking down a URL
The Break down a URL mode splits a link into protocol, host, port, path, query and fragment, and lists every query parameter decoded. It's handy for reading tracking links, debugging API calls or checking redirects. If the link has utm_, fbclid or gclid tracking parameters, you also get a clean version without them.
Everything runs in your browser and nothing is sent anywhere.
Frequently asked questions
What is URL encoding?
Replacing characters that aren’t safe in URLs with a % sign and their UTF-8 byte values in hex. A space becomes %20.
What does %20 mean in a URL?
It is an encoded space. %20 is the hex code of the space character.
Should spaces be %20 or +?
In paths, always %20. In query strings sent by HTML forms, + also means space. %20 works everywhere.
What is the difference between encodeURI and encodeURIComponent?
encodeURIComponent encodes URL structure characters like / ? & =, so it is right for values. encodeURI leaves them, so it is only for full URLs.
How do I decode a URL?
Choose Decode and paste the encoded text. Each %XX code is turned back into its character.
Last updated October 2026 · More developer tools