URL Encoded Characters: %20, %26, %2C (Comma) and More
By Shah Zaib · Published · Updated
In short: when you encode a single value, a space is %20, an ampersand is %26, a comma is %2C, a slash is %2F, a plus is %2B and a hash is %23. Pick Full URL mode instead and the slash, comma, plus and hash stay as they are, because they give the address its shape. The table below is what the URL Encoder & Decoder gives for each of them.
Percent-encoded values for common characters
| Character | Name | Component | Full URL | Component with + for spaces | RFC 3986 |
|---|---|---|---|---|---|
| (space) | Space | %20 | %20 | + | Must be encoded |
| ! | Exclamation mark | ! | ! | ! | Reserved, separator |
| " | Double quote | %22 | %22 | %22 | Must be encoded |
| # | Hash | %23 | # | %23 | Reserved, structure |
| $ | Dollar sign | %24 | $ | %24 | Reserved, separator |
| % | Percent sign | %25 | %25 | %25 | Must be encoded |
| & | Ampersand | %26 | & | %26 | Reserved, separator |
| ' | Apostrophe | ' | ' | ' | Reserved, separator |
| ( | Opening bracket | ( | ( | ( | Reserved, separator |
| ) | Closing bracket | ) | ) | ) | Reserved, separator |
| * | Asterisk | * | * | * | Reserved, separator |
| + | Plus | %2B | + | %2B | Reserved, separator |
| , | Comma | %2C | , | %2C | Reserved, separator |
| / | Slash | %2F | / | %2F | Reserved, structure |
| : | Colon | %3A | : | %3A | Reserved, structure |
| ; | Semicolon | %3B | ; | %3B | Reserved, separator |
| < | Less than | %3C | %3C | %3C | Must be encoded |
| = | Equals | %3D | = | %3D | Reserved, separator |
| > | Greater than | %3E | %3E | %3E | Must be encoded |
| ? | Question mark | %3F | ? | %3F | Reserved, structure |
| @ | At sign | %40 | @ | %40 | Reserved, structure |
| [ | Opening square bracket | %5B | %5B | %5B | Reserved, structure |
| ] | Closing square bracket | %5D | %5D | %5D | Reserved, structure |
Component is for one value, such as a search term or a link that goes inside another link. Full URL is for a whole address that has spaces or non-English letters in it. The + option only changes the space.
Why some characters stay and others change
The URL standard sorts characters into three groups. Letters, digits and four marks can appear anywhere. A set of reserved characters has a job in the address, so they are encoded when you mean them as data. Everything else must be encoded.
Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde.
IETF: RFC 3986: URI generic syntaxThe purpose of reserved characters is to provide a set of delimiting characters that are distinguishable from other data within a URI.
IETF: RFC 3986: URI generic syntaxgen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
IETF: RFC 3986: URI generic syntaxsub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
IETF: RFC 3986: URI generic syntax
An encoded character is a percent sign and two hex digits for each byte. A reserved character written as data and the same character written as %XX are different addresses, so do not encode a whole link with Component mode.
A percent-encoded octet is encoded as a character triplet, consisting of the percent character "%" followed by the two hexadecimal digits representing that octet's numeric value.
IETF: RFC 3986: URI generic syntaxURIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent.
IETF: RFC 3986: URI generic syntax
Space: %20 or +
%20 is a space anywhere in a URL. A + means a space only in form data, the application/x-www-form-urlencoded format that an HTML form sends. In a path a + is a plain plus sign, which is why a plus you mean as data is encoded as %2B. The standard describes the form rule like this:
If spaceAsPlus is true and byte is 0x20 (SP), then append U+002B (+) to output and continue
WHATWG: URL Standard
The tool's + option swaps %20 for + and changes nothing else. A browser form also encodes more characters than Component mode does:
The application/x-www-form-urlencoded percent-encode set is a percent-encode set consisting of the component percent-encode set and U+0021 (!), U+0027 (') to U+0029 RIGHT PARENTHESIS, inclusive, and U+007E (~).
WHATWG: URL Standard
So "hello world!" comes out as hello+world! here, while a form submit would send hello+world%21. Both decode to the same text.
Letters outside A to Z
A letter outside plain ASCII is written as the percent signs of its UTF-8 bytes: é is %C3%A9, so café becomes caf%C3%A9, and the euro sign is %E2%82%AC. Urdu letters work the same way: ا is %D8%A7.
Frequently asked questions
What does %20 mean in a URL?
%20 is an encoded space: 20 is the hex code of the space character. A file called my cv.pdf is linked as my%20cv.pdf.
What does %2C mean in a URL?
%2C is an encoded comma: 2C is the hex code of the comma character. A list value of red,blue is sent as red%2Cblue when the comma is data and not a separator.
Sources: IETF, RFC 3986: URI generic syntax
How do I write an ampersand in a URL?
As %26 when it is part of a value, for example a query value of a&b is sent as a%26b. A plain & is the separator between parameters, so only leave it unencoded when you mean that.
Sources: IETF, RFC 3986: URI generic syntax
How do I put a slash or a comma inside a query value?
Encode the slash as %2F and the comma as %2C. Component mode does both. Full URL mode keeps them, because in a whole address they separate the path and list items.
Sources: IETF, RFC 3986: URI generic syntax
Is + a space or a plus sign in a URL?
It depends where it sits. In form data and query strings sent by an HTML form, + means a space. In a path, and anywhere else, + is a plus sign, and a plus you mean as data is written %2B.
Sources: WHATWG, URL Standard
Why is the hash encoded as %23?
A bare # starts the fragment of the address, so a hash that is part of a value, such as C#, is written as %23.
Sources: IETF, RFC 3986: URI generic syntax