URL Encoder-Decoder
A URL encoder is a utility that transforms text strings into a format suitable for use within web addresses. It achieves this by replacing unsafe characters, such as spaces and symbols, with their percent-encoded equivalents.
Input
Output
What is URL encoding?
URL Encoding (also known as percent-encoding) is a method to encode arbitrary data in a uniform resource identifier (URI) using only the ASCII characters legal within a URI.
URLs are designed to use characters from the ASCII character set. Because URLs often need to include characters outside this set (like spaces or non-ASCII characters), or characters with special meaning within the URL syntax, URL encoding is necessary.
How URL-Encoding works?
ASCII Characters:
For ASCII characters (code points 0–127), URL encoding checks if the character is "unreserved" (like letters, digits, -, _, ., ~). If it’s not, the character is replaced with a percent sign %followed by its two-digit hexadecimal ASCII value. For example, the space character ( ) has an ASCII value of 32, which is0x20in hex, so it becomes %20. Similarly,@ (ASCII 64) becomes %40.
Non-ASCII Characters:
For non-ASCII characters (code points above 127), the character is first encoded using UTF-8 into one or more bytes. Each byte is then percent-encoded separately. For instance, the Unicode character ✓ (U+2713) is UTF-8 encoded into three bytes: E2 9C 93, and these are percent-encoded as %E2%9C%93. This ensures characters from all languages and symbols can be safely represented in URLs using only ASCII-compatible sequences.
RFC 3986 defines "reserved characters" as those that have special meaning within the URL syntax. These characters must be encoded when they appear as data within a URL component, to prevent them from being misinterpreted as URL syntax.
| Character | Hex | URL Encoded |
|---|---|---|
| ! | 21 | %21 |
| @ | 40 | %40 |
| # | 23 | %23 |
| $ | 24 | %24 |
| & | 26 | %26 |
| ' | 27 | %27 |
| ( | 28 | %28 |
| ) | 29 | %29 |
| * | 2A | %2A |
| + | 2B | %2B |
| , | 2C | %2C |
| / | 2F | %2F |
| : | 3A | %3A |
| ; | 3B | %3B |
| = | 3D | %3D |
| ? | 3F | %3F |
| [ | 5B | %5B |
| ] | 5D | %5D |
