URL encoding (also called percent-encoding) is essential for transmitting data over the web safely. Every time you submit a form, paste a URL with special characters, or send data via query parameters — URL encoding is working behind the scenes.
Understanding URL Encoding
The HTTP protocol only allows a limited set of characters in URLs: letters, digits, hyphens, underscores, tildes, and periods. All other characters must be encoded using percent-encoding, which converts each byte to a %XX format where XX is the hexadecimal ASCII code of the character.
⚡ Try the URL Encoder/Decoder
Encode or decode any URL instantly with our free URL Encoder/Decoder tool. Handles special characters, spaces, Unicode, and full URLs.
When Do You Need URL Encoding?
- Query parameters — spaces and special chars in search queries (
?q=hello world→?q=hello%20world) - Path parameters — file names with spaces or non-ASCII characters
- Form submissions —
application/x-www-form-urlencodedformat - API requests — embedding JSON or special characters in query strings
- Bookmarklets — JavaScript URLs with encoded parameters
Key Characters Reference
| Character | Encoded | Use Case |
|---|---|---|
(space) | %20 | Most common encoding in URLs |
# | %23 | Fragment identifier — do NOT encode in path |
& | %26 | Query param separator — encode in values |
= | %3D | Key-value assignment — encode in values |
/ | %2F | Path separator — encode in path segments |
? | %3F | Query string start — encode in path |
+ | %2B | Reserved — often used for space in query values |
世 (Unicode) | %E4%B8%96 | Multi-byte UTF-8 encoded as multiple %XX pairs |
URL Encoding in Different Languages
JavaScript
// Encode
encodeURIComponent("hello world"); // "hello%20world"
encodeURI("https://example.com/a b"); // "https://example.com/a%20b"
// Decode
decodeURIComponent("hello%20world"); // "hello world"
Python
from urllib.parse import quote, urlencode, unquote
# Encode
quote("hello world") # "hello%20world"
quote("hello world", safe="") # force encode spaces
# Query dict
urlencode({{"name": "Alice", "city": "New York"}})
# "name=Alice&city=New%20York"
# Decode
unquote("hello%20world") # "hello world"
URL Safe Encoding
// encodeURI does NOT encode: A-Za-z0-9-_.~
// Use encodeURIComponent for individual values (aggressive)
// Use encodeURI for full URLs (preserves structural chars)
Common Mistakes to Avoid
- Don't double-encode — encode before sending, decode on receipt. Encoding twice produces
%2520instead of%20 - Don't encode full URLs with
encodeURIComponent - — use
encodeURIinstead, which preserves:/?#[]@!$&'()*+,;= - Encode path segments separately — each path segment should be encoded independently
- Handle Unicode properly — always UTF-8 encode before percent-encoding
⚡ URL Encoder / Decoder
Encode and decode URLs with full Unicode support. Use the free tool →