How to Encode Special Characters in URLs
Part of the Encoding Toolkit| Character | Encoded | |
|---|---|---|
| (space) | %20 | |
| & | %26 | |
| = | %3D | |
| ? | %3F | |
| # | %23 | |
| / | %2F | |
| + | %2B | |
| % | %25 | |
| @ | %40 | |
| : | %3A | |
| " | %22 | |
| ' | ' | left as-is by encodeURIComponent (a documented JS quirk — still valid either way) |
Explanation
A "special character" here means anything outside the small unreserved set — letters, digits, -, _, ., and ~ — that a URL leaves untouched. Everything else either has structural meaning somewhere in a URL (& separates query parameters, / separates path segments, and so on) or falls outside plain ASCII, and needs to be percent-encoded: a % followed by two hex digits for each byte.
The table above covers the characters that come up constantly — punctuation in search queries, & and = in values that need to survive inside a query string, / in a value that isn't meant to be a path separator. For the complete reserved-character breakdown by RFC 3986 category, see What Characters Need URL Encoding?. For the one character people search for most on its own, see How to Encode Spaces in URLs.
Valid examples
100%25%20off"100% off" — both the % and the space encoded.
C%2B%2B%20%26%20Rust%3F"C++ & Rust?" — +, space, &, and ? all encoded.
a%2Fb%3Fc%3Dd"a/b?c=d" as a single value — / ? = all encoded so they can't be misread as URL structure.
Invalid examples
C++ & Rust?Left unencoded — & and ? will be read as query-string structure, not literal characters, the moment this becomes part of a URL.
100%offA raw % with no encoding — a lone % not followed by two hex digits is a malformed percent-encoded sequence.
100%2525%2520offDouble-encoding — the % from the first encoding pass got encoded again on a second pass.