%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
| Encoded | Decodes to | What it is | Open in the decoder |
|---|---|---|---|
| q=hello%21 | q=hello! | A search term ending in an exclamation mark. | Open in decoder |
| %23%21%2Finbox | #!/inbox | A 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.
| Language | Function | Output for ! |
|---|---|---|
| JavaScript | encodeURIComponent | kept |
| JavaScript | encodeURI | kept |
| JavaScript | URLSearchParams | %21 |
| JavaScript | escape (deprecated) | %21 |
| Python | quote (default safe='/') | %21 |
| Python | quote (safe='') | %21 |
| Python | quote_plus | %21 |
| C# | Uri.EscapeDataString | %21 |
| C# | WebUtility.UrlEncode | kept |
| C# | HttpUtility.UrlEncode | kept |
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
%3D
equals sign
%3D is the percent-encoded equals sign (=).
%26
ampersand
%26 is the percent-encoded ampersand (&).
%2C
comma
%2C is the percent-encoded comma (,).
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
Tools
URL Encoder
Percent-encode a value, a full URL or form data, with strict RFC 3986 and +/%20 options.
URL Parser
Split a URL into scheme, host, port, path, query and fragment, with checks for common problems.
Query String Parser
Edit query parameters as a table, rebuild the string, or export it as JSON.
Base64 Encode/Decode
Convert text to Base64 and back, including the URL-safe Base64URL alphabet.
HTML Encode/Decode
Escape text to HTML entities and decode entities back to text.
JWT Decoder
Read a JSON Web Token's header and payload and check its expiry.