The journal
What is the point of URL encoding?
A clear explanation of percent-encoding, which characters are affected, when to apply it, and how it differs in purpose from other encodings when placing data in URLs.

URL encoding exists to make URLs unambiguous and reliably parseable. It replaces characters that would otherwise be treated as URL syntax with a percent sign followed by two hexadecimal digits, so browsers and servers transmit and interpret the link correctly MDN percent-encoding.
What URL encoding does
Percent-encoding maps a character to its byte value: a percent sign followed by two hex digits representing the ASCII value of that character. For example, a space becomes %20, a question mark becomes %3F, an ampersand becomes %26, and the percent sign itself becomes %25 MDN percent-encoding.
Why this matters
Characters like :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =, and % have special meaning in URLs. Encoding them when they are part of data (rather than structure) prevents them from being misread as delimiters or control characters MDN percent-encoding.
How percent-encoding works in practice
Only certain characters require encoding; letters and digits are usually left as-is. When you place arbitrary text in a URL component, encode characters that would otherwise be treated as URL syntax so the receiving side can decode them and recover the original value MDN percent-encoding.
Note: in some contexts a space can appear as + instead of %20 (for example, in application/x-www-form-urlencoded). In a URL, it is typically represented as %20 MDN percent-encoding.

Use built-in encoders
Most platforms provide standard functions to percent-encode, such as encodeURI and encodeURIComponent in the Web platform MDN percent-encoding. Use these rather than crafting % sequences by hand.
When to encode
- Before inserting user input or arbitrary text into a query value or path segment, percent-encode it so it cannot be misinterpreted as URL structure MDN percent-encoding.
- When composing full URLs programmatically, encode only the component you are assembling (for example, parameter values) to avoid altering reserved characters that belong to the URL's structure MDN percent-encoding.
- When logging or testing, verify that decoding on the server restores the original text, including spaces and punctuation MDN percent-encoding.
URL encoding vs other encodings (like base64)
Percent-encoding is about URL syntax. Other encodings may transform data for different reasons, but they do not make a string inherently safe for placement in a URL. If a string you plan to include in a URL contains characters that are special in URLs (for example + or /), those characters still need percent-encoding when they appear in data positions, regardless of how the string was produced MDN percent-encoding.
Concrete example
Suppose a query value contains a literal &. If you send it raw, the & would be read as a parameter separator. Encoding it as %26 ensures the entire value is received as intended MDN percent-encoding.
Common pitfalls and quick checks
- Encoding the percent sign itself:
%is encoded as%25. If you see%25in logs where you expected%, the percent sign was encoded. This often appears when the same value was encoded more than once MDN percent-encoding. - Encoding the wrong scope: use component-level encoders for parameter values so you don't accidentally alter structural characters that belong to the URL itself MDN percent-encoding.
- Assuming spaces are always
+: in URLs a space is commonly%20. Be clear about the context your tooling uses MDN percent-encoding.
Apply URL encoding safely
