What is URL Encoding?
URL encoding (also called percent-encoding) converts characters that are not allowed in URLs into a safe format. Each unsafe character is replaced by a % followed by two hexadecimal digits representing the character's ASCII code.
For example, a space becomes %20, and & becomes %26. This ensures URLs are valid and can be transmitted correctly over the internet.
Common Uses
- Encoding query string parameters that contain spaces or special characters.
- Safely embedding URLs inside other URLs (redirect parameters).
- Building API requests where parameter values contain special characters.
- Decoding encoded URLs received from logs, analytics, or API responses.
Common Percent-Encoded Characters
Only unreserved characters (A–Z, a–z, 0–9, - _ . ~) are safe unencoded inside a query parameter value. Everything else must be percent-encoded.
| Character | Encoded | Notes |
|---|---|---|
Space | %20 | Most common encoding issue; also written + in form data |
! | %21 | Exclamation mark |
# | %23 | Reserved — marks fragment identifier |
& | %26 | Reserved — separates query parameters |
+ | %2B | Plus sign (also encodes space in form data) |
/ | %2F | Reserved — path segment separator |
: | %3A | Reserved — separates scheme from host |
= | %3D | Reserved — separates key from value |
? | %3F | Reserved — marks start of query string |
@ | %40 | At sign |
[ | %5B | Open square bracket |
] | %5D | Close square bracket |
Frequently Asked Questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a full URL and leaves characters like / ? # & intact. encodeURIComponent encodes everything including those characters — use it for individual query parameter values. This tool uses encodeURIComponent.
Why does a space become %20 and not +?
Both are valid but in different contexts. %20 is standard percent-encoding (RFC 3986). + is used in HTML form encoding (application/x-www-form-urlencoded). For URLs, %20 is the correct choice.
Is URL encoding the same as Base64?
No. URL encoding converts unsafe URL characters to %XX sequences. Base64 converts binary data to a text string using 64 printable characters. They solve different problems.