%21 is the URL-encoded exclamation mark (!).
In a URL, %21 stands for the exclamation mark (!). Here is when to encode it, what it does in each part of a URL, and what every major language outputs.
Quick facts
| Character | ! |
|---|---|
| Name | Exclamation mark |
| Unicode | U+0021 |
| UTF-8 bytes | 21 (1 byte) |
| Percent-encoded | %21 |
| Lowercase form | %21 — identical meaning |
| Double-encoded | %2521 |
| HTML form encoding | %21 |
| RFC 3986 class | Reserved — sub-delimiter |
What it means in a URL
The exclamation mark is a sub-delimiter in RFC 3986: allowed raw in paths and queries, but reserved for schemes that give it meaning. JavaScript’s encodeURIComponent leaves it unencoded; PHP, Python, Java, Go and Ruby encode it as %21.
RFC 3986 class: Reserved — sub-delimiter. RFC 3986 allows it raw in paths and queries, but some schemes and servers give it meaning, so encoding it as data is the safe choice.
When to encode it
| Where it appears | What to do |
|---|---|
| Path segment | Allowed raw (encoding is also fine) |
| Query value | Allowed raw (encoding is also fine) |
| Fragment | Allowed raw |
| Form body | Encode |
The mistake to watch for
Signature mismatches in OAuth 1.0a or AWS SigV4, which require ! to be encoded as %21 — and encodeURIComponent doesn’t do that.
What each language produces
Left as-is by JavaScript encodeURIComponent(s), JavaScript encodeURI(s); every other function in the table encodes it. Output for the single character, UTF-8 input, tested against the real runtimes (see the encoding comparator for your own strings).
| Function | Output | |
|---|---|---|
| JavaScript encodeURIComponent(s) | ! | kept |
| JavaScript encodeURI(s) | ! | kept |
| JavaScript URLSearchParams | %21 | encoded |
| Python urllib.parse.quote(s) | %21 | encoded |
| Python quote(s, safe="") | %21 | encoded |
| Python urllib.parse.quote_plus(s) | %21 | encoded |
| PHP rawurlencode($s) | %21 | encoded |
| PHP urlencode($s) | %21 | encoded |
| Java URLEncoder.encode(s, UTF_8) | %21 | encoded |
| Go url.QueryEscape(s) | %21 | encoded |
| Go url.PathEscape(s) | %21 | encoded |
| Ruby URI.encode_www_form_component(s) | %21 | encoded |
| Ruby ERB::Util.url_encode(s) | %21 | encoded |
| C# / .NET Uri.EscapeDataString(s) | %21 | encoded |
Decoding it
decodeURIComponent('%21') returns the exclamation mark (!). Python: urllib.parse.unquote('%21'); PHP: rawurldecode('%21'). Paste any string into the URL decoder to decode it in your browser.
Common questions.
%21 is the percent-encoded form of the exclamation mark (!), whose byte value is 0x21. Decoding the URL turns it back into the character.
Yes. Hex digits in percent-encoding are case-insensitive, so %21 and %21 mean the same thing. RFC 3986 recommends uppercase, and mixing cases can make caches and analytics count one URL as two.
Use your language’s encoder on the value: encodeURIComponent in JavaScript gives !, Python’s quote(s, safe="") gives %21, PHP’s rawurlencode gives %21.
More from the toolkit.
About this page. Written and maintained by Sri Murugan Systems, the developer of urlencodedecode.com. Character classes follow RFC 3986 §2; language outputs were generated by running each function in its real runtime.