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 | %20 | In forms also written as + (application/x-www-form-urlencoded) |
| ! | %21 | Exclamation mark |
| # | %23 | Fragment identifier delimiter |
| $ | %24 | Dollar sign |
| & | %26 | Query parameter delimiter |
| ' | %27 | Single quote |
| ( | %28 | Left parenthesis |
| ) | %29 | Right parenthesis |
| * | %2A | Asterisk |
| + | %2B | Plus (represents space in forms) |
| , | %2C | Comma |
| / | %2F | Path delimiter |
| : | %3A | Scheme/host delimiter |
| ; | %3B | Parameter delimiter |
| = | %3D | Key-value delimiter |
| ? | %3F | Query start |
| @ | %40 | Userinfo delimiter |
| [ | %5B | Left square bracket |
| ] | %5D | Right square bracket |
| % | %25 | Percent itself must be encoded |
| " | %22 | Double quote |
| < | %3C | Less-than sign |
| > | %3E | Greater-than sign |
| \ | %5C | Backslash |
| ^ | %5E | Caret |
| ` | %60 | Backtick |
| { | %7B | Left curly brace |
| | | %7C | Vertical bar |
| } | %7D | Right curly brace |
| ~ | %7E | Tilde |
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.