%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!
NameExclamation mark
UnicodeU+0021
UTF-8 bytes21 (1 byte)
Percent-encoded%21
Lowercase form%21 — identical meaning
Double-encoded%2521
HTML form encoding%21
RFC 3986 classReserved — 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 appearsWhat to do
Path segmentAllowed raw (encoding is also fine)
Query valueAllowed raw (encoding is also fine)
FragmentAllowed raw
Form bodyEncode

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).

FunctionOutput
JavaScript encodeURIComponent(s)!kept
JavaScript encodeURI(s)!kept
JavaScript URLSearchParams%21encoded
Python urllib.parse.quote(s)%21encoded
Python quote(s, safe="")%21encoded
Python urllib.parse.quote_plus(s)%21encoded
PHP rawurlencode($s)%21encoded
PHP urlencode($s)%21encoded
Java URLEncoder.encode(s, UTF_8)%21encoded
Go url.QueryEscape(s)%21encoded
Go url.PathEscape(s)%21encoded
Ruby URI.encode_www_form_component(s)%21encoded
Ruby ERB::Util.url_encode(s)%21encoded
C# / .NET Uri.EscapeDataString(s)%21encoded

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.

← %20 Space  ·  Full URL encoding table  ·  %22 Double quote →

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.