What Is URL Encoding?
URLs can only contain a limited set of ASCII characters. When a URL includes spaces, non-ASCII characters (like Chinese or Arabic), or characters that have special meaning in URLs (like & or =), those characters must be converted to a safe format โ this is URL encoding, also called percent-encoding.
For example: the space character becomes %20 because its ASCII hex value is 20. So hello world becomes hello%20world in a URL.
Why Does URL Encoding Exist?
- Spaces aren't allowed in URLs
- Special characters have reserved meanings โ
&, =, ?, and # structure URLs, so they must be encoded when they appear as data
- Non-ASCII characters must be converted to UTF-8 bytes first, then each byte percent-encoded
Use the tool.tl URL Encoder or URL Decoder โ paste any text to convert it instantly:
- Go to tool.tl/url-encoder (to encode) or tool.tl/url-decoder (to decode)
- Paste your text into the input box
- See the result update in real time
- Click "Copy" to use the output
Common URL Encoding Reference
| Character | URL Encoded | Notes |
| Space | %20 or + | + used in query strings only |
| ! | %21 | |
| # | %23 | Normally marks a fragment/anchor |
| % | %25 | The percent sign itself |
| & | %26 | Separates query parameters |
| / | %2F | Path separator |
| = | %3D | Key=value separator |
| ? | %3F | Starts query string |
| @ | %40 | |
URL Encoding vs. Base64 Encoding
| URL Encoding | Base64 Encoding |
| Purpose | Pass special characters safely in URLs | Encode binary data as text |
| Output | %XX format | A-Z, a-z, 0-9, +/= |
| Readability | Partially readable | Not human-readable |
| Size increase | Variable (depends on chars) | ~33% larger |
| Typical use | Query parameters, form submissions | Embedding images, API payloads |
Common URL Encoding Pitfalls
Double Encoding
If you encode an already-encoded string, %20 becomes %2520 (because % itself gets encoded to %25). Always decode before re-encoding to avoid this.
+ vs %20 in Spaces
In query strings submitted via HTML forms (application/x-www-form-urlencoded), + means space. In the URL path, only %20 is correct for spaces โ never use + there.
Encoding in JavaScript
Use encodeURIComponent() for individual parameter values (encodes everything except letters, digits, and - _ . ! ~ * ' ( )). Use encodeURI() for full URLs (preserves structural characters like :/?&=). Decode with decodeURIComponent() and decodeURI() respectively.
Frequently Asked Questions
What's the difference between %20 and + for spaces?
Both represent spaces, but in different contexts. %20 is valid anywhere in a URL. + only means space inside HTML form data (query strings). In URL paths, always use %20.
How do I URL-encode a string in Python?
Use urllib.parse.quote(string) for URL path encoding or urllib.parse.quote_plus(string) for form data (converts spaces to +). Decode with urllib.parse.unquote().
Why do some URLs show readable characters while others show %XX codes?
Modern browsers decode percent-encoded characters for display in the address bar โ what you see is the human-readable version. The actual HTTP request still uses the encoded form. This is purely a display convenience.
Can I use the URL encoder for Base64 too?
They serve different purposes. For Base64, use the dedicated Base64 Encoder or Base64 Decoder tools instead.