Percent-Encoding in URLs: What Those %20s Actually Mean
Percent-encoding (also called URL encoding) is the mechanism for representing characters in URLs that are either not allowed by the URL specification or that have special structural meaning. Every web developer has seen %20 for a space or %2F for a slash, but the full rules are more nuanced.
How Percent-Encoding Works
A percent-encoded character is represented as %XX, where XX is the hexadecimal byte value. The space character (U+0020, decimal 32, hex 0x20) becomes %20. For non-ASCII characters, the character is first encoded as UTF-8, then each byte of the UTF-8 sequence is percent-encoded separately. The Euro sign € (U+20AC) encodes to three UTF-8 bytes (0xE2 0x82 0xAC), so it appears in URLs as %E2%82%AC.
Reserved Characters
Some characters are "reserved" in URLs because they have structural roles: / separates path segments, ? starts the query string, & separates query parameters, # starts a fragment. These characters must be percent-encoded when they appear as data rather than structure. Other characters — letters, digits, -, _, ., ~ — are "unreserved" and don't need encoding.
Query Strings and Forms
HTML forms submitted with method="GET" use a variant called application/x-www-form-urlencoded, where spaces become + (not %20) and other special characters are percent-encoded. This +-for-space convention applies only to query strings, not to path segments, which always use %20. This distinction is a common source of bugs.
Internationalized URLs (IRIs)
RFC 3987 defines Internationalized Resource Identifiers (IRIs), which allow Unicode characters directly in URLs without percent-encoding. Browsers display the human-readable IRI while transmitting the percent-encoded URL. A URL like https://例え.jp/path is transmitted as https://xn--r8jz45g.jp/path (using Punycode for the domain) and https://例え.jp/path in display form. Use our encoder to convert any character to its percent-encoded form.