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.

How It Works

Percent-encoding is the URL-safe representation mandated by RFC 3986. A URL may contain only a small set of "unreserved" characters (letters, digits and - _ . ~) literally; everything else — reserved characters used outside their delimiter role, spaces, and any non-ASCII character — must be escaped so the parser does not mistake it for structure.

Rule: encode the character as UTF-8 bytes, then write each byte as %XX (XX = two uppercase hex digits). For example the Chinese character 中 is UTF-8 E4 B8 AD, encoded as %E4%B8%AD. Reserved chars (like ? # / & =) are only encoded when not used as delimiters — that is why ? separates the query but becomes %3F inside a value.

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.