Why URLs Cannot Contain Every Character
A URL is text, but it is special text. The URL specification (RFC 3986) defines a strict set of characters that are allowed — letters, digits, and a handful of special characters like -, _, ., and ~. Characters outside this set must be encoded before they appear in a URL.
The reason is ambiguity. Some characters have special meaning in URL syntax. The ? separates the path from the query string. The & separates query parameters from each other. The = separates parameter names from values. The # starts a fragment identifier.
If your query parameter value contains a &, the URL parser would interpret it as the end of that parameter and the start of the next one. To include these characters literally, they must be encoded in a way that tells the parser "this is data, not structure."
How Percent Encoding Works
Percent encoding replaces each unsafe character with a % sign followed by the two-digit hexadecimal ASCII code for that character.
Space is ASCII 32. In hexadecimal, 32 is 20. So a space becomes %20. That is all. You can verify any character: look up its ASCII code, convert to hex, add a % in front.
A few common encodings worth knowing:
- Space →
%20(or+in form encoding) @→%40:→%3A/→%2F?→%3F=→%3D&→%26
Non-ASCII characters (accented letters, Chinese characters, emoji) are first converted to their UTF-8 byte sequences, and then each byte is percent-encoded. An emoji might become several %xx sequences in a URL.
The Two Types of URL Encoding
URL encoding (also called percent encoding) — encodes everything that is not in the allowed set of unreserved characters. Used for encoding entire URLs or URI components.
Form encoding — Used specifically for HTML form data submitted via GET or POST. Nearly identical to percent encoding but uses + instead of %20 for spaces. This is what browsers use when you submit a form.
You see both in the wild. An API endpoint might use %20 for spaces in its URL structure, while form submissions use +. Knowing the difference prevents subtle bugs when building or debugging APIs.
Practical Uses for URL Encoding
Building API requests — Any query parameter that might contain special characters needs to be URL-encoded before being appended to a URL. Most HTTP libraries do this automatically, but knowing what is happening helps when debugging raw requests.
Reading server logs — Log files show encoded URLs. Decoding them makes the actual paths and parameters readable.
Debugging redirects — Redirect chains often involve URL-encoded destination URLs nested inside other URL parameters. Decoding these step by step reveals the actual redirect target.
Our URL Encoder/Decoder tool handles both encoding and decoding instantly. Paste a URL or text string and get the encoded or decoded result immediately, no installation required.
Related Topics
Try it yourself
URL Encoder / Decoder
Everything in this article is available in the free tool. No account, no subscription, no install.
Open URL Encoder / Decoder →