%url-decoder.net

%21 in a URL

The percent-encoded exclamation mark (!).

Short answer

%21 is the percent-encoded exclamation mark (!). RFC 3986 lists ! as a sub-delimiter, so it is allowed in URLs, but functions disagree on encoding it: encodeURIComponent leaves it alone, while URLSearchParams and Python's quote write %21.

Character
!
Percent-encoded
%21
Byte value
0x21 = 33
RFC 3986 class
sub-delim
UTF-8 bytes
1

Where you will see it

  • Values produced by form encoders or strict RFC 3986 encoders: q=hello%21.
  • Hash-bang addresses from older single-page apps: #!/inbox.
  • Titles and search terms that end with an exclamation mark.

What goes wrong

  • Because encodeURIComponent keeps ! but URLSearchParams and Uri.EscapeDataString encode it, the same value can be written two ways. Both decode to the same text, but signing schemes that compare the encoded string, such as OAuth 1.0 and AWS Signature Version 4, require the strict form %21.
  • To get the strict form in JavaScript, encode with encodeURIComponent and then replace ! ' ( ) * with their %XX codes, as MDN shows.

Decoded examples

EncodedDecodes toWhat it isOpen in the decoder
q=hello%21q=hello!A search term ending in an exclamation mark.Open in decoder
%23%21%2Finbox#!/inboxA hash-bang fragment, #!/inbox, encoded as a value.Open in decoder

How each language encodes !

Outputs below come from running each function, not from documentation. “Kept” means the function leaves the character as it is. Compare every character across every function.

LanguageFunctionOutput for !
JavaScriptencodeURIComponentkept
JavaScriptencodeURIkept
JavaScriptURLSearchParams%21
JavaScriptescape (deprecated)%21
Pythonquote (default safe='/')%21
Pythonquote (safe='')%21
Pythonquote_plus%21
C#Uri.EscapeDataString%21
C#WebUtility.UrlEncodekept
C#HttpUtility.UrlEncodekept

Questions

Do I need to encode an exclamation mark in a URL?

Not usually: ! is a legal sub-delimiter. Encode it when the receiver compares encoded strings, as OAuth 1.0 and AWS request signing do, or when you want one consistent form.

Why doesn't encodeURIComponent encode the exclamation mark?

It follows the older RFC 2396 rules, where ! ' ( ) * were unreserved marks. RFC 3986 later made them reserved sub-delimiters, so strict encoders now escape them.

Decode or encode your own text

Paste anything containing %21. It runs in your browser; nothing is uploaded.

Related characters

All percent-encoded characters · Full percent-encoding table · What is URL encoding?

Behaviour checked against RFC 3986, the WHATWG URL Standard and MDN. Updated November 4, 2026