URLs are restricted to a specific set of safe characters. When a URL needs to contain anything outside that set — spaces, accented letters, special symbols, or characters from Urdu or other languages — percent-encoding converts each unsafe character to its safe equivalent.
How Percent-Encoding Works
Each character that isn't URL-safe is replaced by %XX, where XX is the hexadecimal value of the character's ASCII (or UTF-8) code.
| Character | Encoded |
|---|---|
| Space | %20 |
| ! | %21 |
| # | %23 |
| $ | %24 |
| & | %26 |
| + | %2B |
| / | %2F (in query strings; in paths it means a separator) |
| ? | %3F |
| @ | %40 |
| = | %3D |
When You See It
- Search queries: a Google search for "web design Lahore" becomes
...q=web+design+Lahoreor...q=web%20design%20Lahorein the URL. - Form submissions: form data with special characters gets encoded before transmission.
- File names in URLs: a file named "My Report 2026.pdf" becomes
My%20Report%202026.pdf. - API parameters: values passed to APIs are often URL-encoded to ensure safe transmission.
Reserved vs Unreserved Characters
Unreserved (always safe, never encoded): A–Z a–z 0–9 - _ . ~
Reserved (have special meaning in URLs): : / ? # [ ] @ ! $ & ' ( ) * + , ; =
Reserved characters are encoded when used as data rather than their structural role. For example, a / in a filename parameter is encoded as %2F so it isn't interpreted as a URL path separator.
Non-ASCII Characters
Urdu and other non-ASCII scripts in URLs use UTF-8 encoding where each byte of the UTF-8 representation is percent-encoded. The Urdu word for "books" (کتابیں) might appear in a URL as a sequence of %D9%... codes.
Encoding and Decoding
Use URL Encoder/Decoder to:
- Encode a string or URL component for safe use in a URL.
- Decode percent-encoded URLs to readable form.
- Debug encoded query strings and parameters.
For Base64 encoding (a different encoding used for binary data in text contexts), see what is Base64 encoding.
URL Encoding in Pakistan Context
Urdu text in URLs — used by Urdu-language websites and news portals — appears heavily encoded because each Urdu character requires multiple UTF-8 bytes, each percent-encoded. A URL like https://example.com/اردو-خبر actually transmits as a long string of %D8%... codes. Modern browsers display the decoded (readable) version in the address bar, but the underlying transmission uses the encoded form. When building URLs programmatically in PHP, urlencode() and rawurlencode() handle this automatically for query strings and path segments respectively.