How Do You URL Encode a Hash Symbol (#)?
The url encoding of "#" is %23. The hash symbol (#) is URL encoded as %23. In URLs, the hash (also called the fragment identifier) separates the main URL from the fragment. When you need a literal # inside a query parameter or path, you must encode it as %23.
Why Encode "#"?
The # character introduces the fragment identifier in a URL (e.g., /page#section). If your data contains a literal hash (e.g., a color code "#FF5733" or a channel name "#general"), encoding it prevents the browser from treating everything after it as a fragment reference.
Encoding Details
| Character | # |
| Encoded form | %23 |
| Encoding type | URL encoding |
| Unicode code point | U+0023 |
Code Examples
JavaScript
encodeURIComponent('#FF5733');
// "%23FF5733"
Python
from urllib.parse import quote
quote('#FF5733')
# '%23FF5733'
Try It Yourself
Use our URL Encoder to encode any character instantly.
Frequently Asked Questions
What is a URL fragment?
The fragment (everything after #) identifies a section within a page. For example, /docs#install scrolls to the "install" section. Fragments are NOT sent to the server -- they are handled entirely by the browser.
Does the server see the # part of a URL?
No. The fragment identifier is never sent in HTTP requests. If you need to send a # to the server, it must be encoded as %23 in the query string.
How do I include a hashtag in a URL parameter?
Encode it as %23. For example: /search?q=%23javascript sends the value "#javascript" to the server. Without encoding, /search?q=#javascript would send q= (empty) and treat "javascript" as a fragment.