What is URL Encoding?
URL encoding (also called percent encoding) converts characters that are not allowed in URLs into a format that can be safely transmitted. Each disallowed character is replaced with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII or UTF-8 value.
For example, a space character becomes %20, the @ symbol becomes %40, and the & symbol becomes %26.
Without URL encoding, a search query containing & would be interpreted as a URL parameter separator, completely breaking the request.
Reserved vs Unreserved Characters
URL characters fall into two categories:
Unreserved characters — safe to use in URLs without encoding: letters A–Z a–z, digits 0–9, and the symbols - _ . ~
Reserved characters — have special meaning in URLs and must be percent-encoded when used as data (not as delimiters):
| Character | Encoded form | URL meaning |
|---|---|---|
| Space | %20 (or +) | Not allowed |
| & | %26 | Parameter separator |
| = | %3D | Key-value separator |
| ? | %3F | Query string start |
| # | %23 | Fragment identifier |
| + | %2B | Sometimes used for space |
| / | %2F | Path separator |
| @ | %40 | Userinfo separator |
How URL Encoding Works
The encoding process converts each character to its UTF-8 byte sequence, then represents each byte as %XX where XX is the hexadecimal value.
Example: encoding the text "hello world & more"
- Space → %20
- & → %26
- Result:
hello%20world%20%26%20more
For non-ASCII characters like accented letters or emoji, each byte of the UTF-8 encoding is encoded separately. The emoji 🎉 (U+1F389) becomes %F0%9F%8E%89.
When Do You Need URL Encoding?
- Search queries — user input passed as a URL parameter must be encoded to prevent breaking the query string.
- API requests — parameters containing special characters must be encoded before being appended to API URLs.
- Form submissions — browsers automatically encode form data, but manual API calls require encoding.
- Redirect URLs — a redirect target URL passed as a parameter must itself be encoded.
- File names in URLs — file names containing spaces or special characters must be encoded.
Encode or decode any URL instantly — paste and convert with one click.
Open URL Encoder →URL Encoding in Code
Every major language includes built-in URL encoding functions:
JavaScript: encodeURIComponent("hello world") — encodes a single component. Use encodeURI() for full URLs.
Python: from urllib.parse import quote; quote("hello world")
PHP: urlencode("hello world")
In JavaScript, use encodeURIComponent() for individual query parameter values, not encodeURI(). The latter does not encode &, =, and ? which are reserved in query strings.
Frequently Asked Questions
Try our free URL Encoder & Decoder — instant results, no sign-up required.
Open URL Encoder & Decoder →