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.

💡 Why it matters

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):

CharacterEncoded formURL meaning
Space%20 (or +)Not allowed
&%26Parameter separator
=%3DKey-value separator
?%3FQuery string start
#%23Fragment identifier
+%2BSometimes used for space
/%2FPath separator
@%40Userinfo 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"

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?

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")

⚠️ Common mistake

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

Both represent a space, but in different contexts. %20 is the standard percent-encoding and works everywhere. The + sign represents a space only in application/x-www-form-urlencoded data (HTML form submissions). Use %20 in URL paths; + is only valid in query strings of form-encoded data.
No. You should only encode the values within a URL — not the protocol, domain, path separators, or query string delimiters. Use encodeURIComponent() for individual values and encodeURI() for a complete URL that may already contain structural characters.
URL encoding replaces special characters with %XX sequences to make them safe for URLs. Base64 converts binary data into a text string using 64 printable characters. They solve different problems — URL encoding is for making data safe in URL context; Base64 is for encoding binary data as text.
The + convention for spaces comes from the HTML form encoding standard (application/x-www-form-urlencoded). Browsers use + when submitting form data. Modern practice prefers %20 as it is unambiguous in all URL contexts.

Try our free URL Encoder & Decoder — instant results, no sign-up required.

Open URL Encoder & Decoder →

Related Articles