URL Encoding Cheat Sheet
Which characters need percent-encoding, what each one becomes, and which function to use in your language.
Cheat sheetPrintableFree, no login
Updated 28 October 2026
Encode or decode text, and split a URL's query string into an editable table.
Open the URL encoderHow percent-encoding works
URL encoding (percent-encoding) replaces a character with % followed by two hex digits for each of its UTF-8 bytes. A space becomes %20; Γ©, which is two bytes in UTF-8, becomes %C3%A9.
- Never needs encoding (unreserved):
AβZ aβz 0β9 - . _ ~ - Reserved β encode when used as data:
: / ? # [ ] @ ! $ & ' ( ) * + , ; = - Always encode: space,
% " < > \ ^ ` { | }, control characters and every non-ASCII character
Percent-encoding table
| Character | Encoded | Note |
|---|---|---|
space | %20 | Space. In form data and query strings often written + |
! | %21 | |
" | %22 | |
# | %23 | Starts the fragment |
$ | %24 | |
% | %25 | Must always be encoded when it's data |
& | %26 | Separates query parameters |
' | %27 | |
( | %28 | |
) | %29 | |
* | %2A | |
+ | %2B | Means space in form data, so encode a real + |
, | %2C | |
/ | %2F | Path separator |
: | %3A | After the scheme and before the port |
; | %3B | |
< | %3C | |
= | %3D | Between a parameter's name and value |
> | %3E | |
? | %3F | Starts the query |
@ | %40 | Separates user info from the host |
[ | %5B | |
\ | %5C | |
] | %5D | |
^ | %5E | |
` | %60 | |
{ | %7B | |
| | %7C | |
} | %7D | |
~ | %7E | Unreserved β normally left as ~ |
Click an encoded value to copy it. Hex digits are case-insensitive, but uppercase (%2F) is recommended.
Non-ASCII characters
encodeURI vs encodeURIComponent
| JavaScript function | Leaves unencoded | Use it for |
|---|---|---|
encodeURIComponent() | AβZ aβz 0β9 - _ . ! ~ * ' ( ) | A single query value or path segment. The right choice most of the time |
encodeURI() | The above plus ; , / ? : @ & = + $ # | A whole URL that is already put together |
new URLSearchParams() | AβZ aβz 0β9 * - . _, space β + | Building query strings and form bodies |
escape() | β | Nothing. Deprecated; it doesn't handle UTF-8 correctly |
For strict RFC 3986, also encode ! ' ( ) * after encodeURIComponent().
URL encoding in other languages
| Language | Query value (space β %20) | Form data (space β +) |
|---|---|---|
| JavaScript | encodeURIComponent(s) | new URLSearchParams({ q: s }).toString() |
| Python | urllib.parse.quote(s, safe='') | urllib.parse.quote_plus(s) or urlencode(dict) |
| PHP | rawurlencode($s) | urlencode($s) |
| Java | URLEncoder.encode(s, StandardCharsets.UTF_8).replace("+", "%20") | URLEncoder.encode(s, StandardCharsets.UTF_8) |
| Go | url.PathEscape(s) | url.QueryEscape(s) |
| C# | Uri.EscapeDataString(s) | WebUtility.UrlEncode(s) |
| curl | curl -G --data-urlencode 'q=a b' URL | same (curl uses %20 for spaces) |
Common mistakes
- Encode the parts, not the whole URL. Running
encodeURIComponenton a full URL turnshttps://intohttps%3A%2F%2Fand breaks it. - Double encoding. Encoding twice turns
%20into%2520. If you see%25followed by two hex digits, something was encoded twice. +vs%20.+means a space only in form data and query strings. In a path,+is a literal plus sign. To send a real+in a query, encode it as%2B.- A lone
%breaks decoding.decodeURIComponent('100%')throws "URI malformed". Encode a literal % as%25. - Paths and queries differ.
/is fine inside a query value but must be%2Finside a single path segment.
Frequently asked questions
What is %20 in a URL?
%20 is an encoded space. Spaces aren't allowed in URLs, so they're replaced with % plus the hex code 20.Should spaces be %20 or +?
Use
%20 in paths and in most APIs. + is only a space in form data (application/x-www-form-urlencoded) and query strings built that way. Decoders for query strings usually accept both.What is the difference between encodeURI and encodeURIComponent?
encodeURI keeps characters that give a URL its structure (: / ? & = #), so use it on a complete URL. encodeURIComponent encodes those too, so use it on a single value you are putting into a URL.Why do I see %2520 in my URL?
The URL was encoded twice:
% became %25, so %20 turned into %2520. Encode once, just before building the URL.Does URL encoding work with emoji and other languages?
Yes. The character is converted to UTF-8 bytes and each byte is encoded, so π becomes
%F0%9F%98%80.