URL Encoding Reference

URL percent-encoding reference: reserved characters mapped to their %XX encodings, with notes for quick lookup when building query strings and paths.

Char编码Note
space%20In forms also written as + (application/x-www-form-urlencoded)
!%21Exclamation mark
#%23Fragment identifier delimiter
$%24Dollar sign
&%26Query parameter delimiter
'%27Single quote
(%28Left parenthesis
)%29Right parenthesis
*%2AAsterisk
+%2BPlus (represents space in forms)
,%2CComma
/%2FPath delimiter
:%3AScheme/host delimiter
;%3BParameter delimiter
=%3DKey-value delimiter
?%3FQuery start
@%40Userinfo delimiter
[%5BLeft square bracket
]%5DRight square bracket
%%25Percent itself must be encoded
"%22Double quote
<%3CLess-than sign
>%3EGreater-than sign
\%5CBackslash
^%5ECaret
`%60Backtick
{%7BLeft curly brace
|%7CVertical bar
}%7DRight curly brace
~%7ETilde

Frequently Asked Questions

Why is a space sometimes %20 and sometimes +?

In application/x-www-form-urlencoded (form submit) a space becomes +; in path/query percent-encoding a space is always %20. Different contexts, do not mix them.

Which characters must be encoded?

RFC 3986 reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) must be encoded when not used as delimiters; also any non-ASCII character (e.g. Chinese) must be encoded.

Why are there two hex digits after %?

Percent-encoding represents a byte as %XX. Non-ASCII chars are first UTF-8 encoded into bytes, then each byte becomes %XX.

What is the difference between URL encoding and Base64?

URL encoding only escapes unsafe characters and keeps structure readable, for URLs. Base64 encodes arbitrary binary into text and changes the content, for transferring binary.