← Blog

2026-05-26

URL Encoding Explained: What %20 Means and How to Fix It

Have you ever seen a URL containing %20, %26, or long strings of percent signs and hexadecimal digits? That is URL encoding — a standard way to represent characters that would otherwise break a URL or be misinterpreted by browsers and servers.

What is URL encoding?

URL encoding (formally called percent encoding) replaces characters that have special meaning in URLs — or that are unsafe to include in a URL — with a percent sign followed by two hexadecimal digits representing the character's byte value.

A space has the byte value 0x20 in ASCII encoding. That is why a space becomes %20 in a URL. An ampersand (&) has value 0x26 — it becomes %26. An equals sign (=) has value 0x3D — it becomes %3D.

URL encoding is defined in RFC 3986, the internet standard for Uniform Resource Identifiers.

Why does URL encoding exist?

URLs can only contain a limited set of characters safely. The RFC defines which characters are considered safe in a URL — letters (A–Z, a–z), digits (0–9), and a small set of symbols: hyphen, underscore, period, and tilde. Characters outside this set have special meanings or are unsafe, so they must be encoded.

Spaces break URL parsing entirely. Ampersands separate query parameters. Equals signs separate keys from values. Hash marks identify fragment identifiers. When these characters appear inside a parameter value, they must be encoded so the URL parser does not misread the structure.

Common URL encoding examples

These are the percent-encoded forms of frequently encountered characters: a space becomes %20, a double quote becomes %22, a hash becomes %23, an ampersand becomes %26, a plus sign becomes %2B, a forward slash becomes %2F, a colon becomes %3A, an equals sign becomes %3D, a question mark becomes %3F, and an at sign becomes %40.

Note that the plus sign (+) is sometimes used to represent a space in query strings formatted as application/x-www-form-urlencoded, which is the format used by traditional HTML form submissions. However, %20 is the universal, unambiguous representation and should be preferred in all other contexts.

How to decode a URL

When you encounter a percent-encoded URL and need to read the original text, paste it into a URL decoder. The decoder replaces each %XX sequence with the corresponding character.

For example: https://example.com/search?q=hello%20world decodes to https://example.com/search?q=hello world.

Most modern browsers decode URLs in the address bar, so you typically see the readable version. Some developer tools, API responses, and server logs show the raw encoded form. To decode in code, use decodeURIComponent() in JavaScript or urllib.parse.unquote() in Python.

Frequently asked questions

What is the difference between %20 and + in a URL?

Both represent a space, but in different contexts. %20 is standard percent encoding and is valid anywhere in a URL. + represents a space only in query strings using application/x-www-form-urlencoded format. When in doubt, use %20.

What does %2F mean in a URL?

%2F is the URL-encoded forward slash (/). Since / separates URL path segments, encoding it as %2F allows a literal slash inside a path segment or query parameter value without it being interpreted as a path separator.

Why does my URL look garbled after copy-pasting?

When you copy a URL from some apps or terminals, non-ASCII characters and spaces are automatically encoded. The encoded version is functionally identical to the original — paste it into a URL decoder to see the readable form.

What is encodeURIComponent in JavaScript?

encodeURIComponent() is a JavaScript function that percent-encodes a string for safe use as a URI component, such as a query parameter value. It encodes everything except letters, digits, and the characters - _ . ! ~ * ' ( ). Use it when building URLs from user-supplied input.