ToolBoxOnline
Developer

URL Encoding: What Those %20 Signs Mean and When to Use Them

Spaces become %20, ampersands become %26, and suddenly your URL works. A practical guide to URL encoding for anyone who's ever copied a link that broke.

url encodingurl encoderpercent encodingencode urldecode url

You copy a link from an email. It has spaces and Chinese characters in it. You paste it into a browser and it is broken — half the characters turned into gibberish. That is because URLs can only contain a limited set of characters. Everything else needs to be encoded.

An online URL encoder does this in one click. Paste your URL, and it converts all the special characters into percent-encoded format that browsers and servers understand.

What gets encoded and why

URLs can only safely contain: letters (A-Z, a-z), numbers (0-9), hyphens, underscores, periods, and tildes. Everything else — spaces, symbols, non-Latin characters — gets converted to a percent sign followed by two hex digits.

Space becomes %20. Ampersand (&) becomes %26. A Chinese character like 中文 becomes %E4%B8%AD%E6%96%87. The browser automatically decodes these back to readable text in the address bar, which is why you see the Chinese characters but the actual URL underneath is encoded.

Characters that always need encoding: space (%20), hash (%23), percent (%25), ampersand (%26), plus (%2B), question mark when not starting a query string, and any byte above 0x7F (all non-ASCII characters).

Common URL encoding mistakes

Double encoding. You encode a URL, then encode it again. %20 becomes %2520 (the % gets encoded to %25). The browser decodes once and you are left with %20 instead of a space. This happens most often when URL encoding is applied at multiple layers — your code encodes, then the framework encodes again.

Encoding the entire URL vs just the query string. You should encode the query parameter values, not the whole URL. https://example.com/search?q=hello%20world is correct. Encoding the entire thing breaks the structure.

Forgetting to decode before displaying. If you show a percent-encoded string to users as-is, it looks broken. Always decode before display. Our URL decoder handles both directions — paste encoded text to see the original.

When you need to manually encode

You need to manually encode URLs when building query strings, working with APIs, or creating links that contain user-generated content. If your URL includes a search term, a username, or any text with special characters, encode it first.

Most programming languages have built-in functions: encodeURIComponent() in JavaScript, urllib.parse.quote() in Python, URLEncoder.encode() in Java. But if you need a quick check without writing code, the online encoder is right there.

Tools mentioned in this article

شارك هذه الأداة