You’ve likely encountered URLs full of strange symbols and percent signs while browsing the internet on your smartphone orChromebook. At first glance, these URLs often look like a mess of random characters. However, they serve an essential purpose. They accurately transmit URLs and data across the web.

Visiting websites and typing URLs into your browser is easy, but things are more complicated behind the scenes. Thanks to URL encoding, a process that converts special characters in a URL into a standardized format, browsing the web is a piece of cake. It allows URLs to include symbols, spaces, and punctuation without breaking them. This is crucial because many web pages would otherwise fail to load correctly.

Screenshot of a Google search highlighting the encoded URL.

URL encoding is a must-know concept if you want to better understand the digital landscape and how the web works. By the end of this guide, those mysterious URLs with percent signs and random characters will make perfect sense.

What is URL encoding?

URL encoding is a process for converting special characters and non-alphanumeric characters into a format that web browsers and servers can understand and safely transmit. It’s a way to represent special characters in a URL so that they don’t cause access issues.

URLs can only be sent usingthe ASCII character set, so any characters outside this set need to be encoded. Thus, the URL encoding process replaces those non-ASCII characters in URLs with a percent sign and a two-digit hexadecimal value.

Screenshot of an Android Police search highlighting the encoded URL.

For instance, the exclamation mark is encoded as%21, the question mark as%3F, and so on. This allows the web browser and server to transmit and adequately load the URL, so you don’t get a massive headache from web page loading issues.

Here are some common encoded symbols you’ll come across:

Any character that isn’t a letter, number, or reserved symbol must be encoded. This includes spaces, foreign language characters, and some emoji.

Spaces in URL encoding

Things can also get a bit more complicated regarding spaces in URLs since both%20and the plus sign (+) are used. This is because the specific usage of%20versus+depends on the URL’s context and encoding requirements.

Generally,%20is used for spaces inURL components(paths, query parameters, and fragments). It’s worth noting that it’s good practice as a web developer to avoid using spaces in these components and instead use hyphens or underscores. This helps to ensure compatibility and avoids potential issues with URL encoding.

Screenshot of a sample encoded URL with symbols in the path.

On the other hand,+is explicitly used in the query string (passes data to a web page) to encode spaces in query parameter values. Search results pages often use query strings to pass the search terms, filtering options, and pagination details from the search form to the results page.

Reserved characters in URLs

Some characters have special meanings in URLs and only need to be encoded if they’re used differently. These characters include:

These reserved characters are used for functions such as delimiters, separating different URL parts, or indicating special characters within a URL. For example, the colon (:) separates the scheme from the rest of the URL (http:// or https://). Similarly, the forward slash (/) separates different path segments in a URL.

Diagram of URL structure.

However, there may be cases where these reserved characters are used in a different context within a URL, such as being part of a path segment or query parameter value. When used in these circumstances without encoding,web browsersor servers might misinterpret them. To avoid confusion and ensure proper interpretation, these reserved characters must be URL encoded when used in a different context.

What parts of a URL are encoded?

Not all parts of a URL need to be encoded. The scheme/protocol, subdomain, domain name, top-level domain, and port (if applicable) don’t typically require encoding.

Query parameters, often found when using a search bar, are encoded. These values come after the question mark in a URL (after the path) and are used to provide additional information to the server. Sometimes, these values can contain special characters like spaces or symbols.

Screenshot of a site not loading due to non-English characters.

Next, the path segments of a URL are also encoded. Path segments are the different parts of a URL that come after the domain name and before any query parameters. If these segments contain special characters like spaces or question marks, it’s essential to encode them. This ensures that these characters are treated as literal characters rather than being interpreted as part of the URL structure.

Fragments, also known as anchors, specify a specific location within a web page. If a fragment contains special characters, they should be encoded to ensure proper interpretation.

URL encoding is also significant when working with URLs that contain non-alphanumeric or special characters, such as punctuation marks or non-English characters. Encoding them ensures the URL remains valid and that web browsers can process it correctly.

Percent signs and gibberish united

URL encoding plays a vital behind-the-scenes role in allowingseamless web browsing. By converting special characters into a standardized format, URL encoding accurately transmits URLs and data between browsers and servers. While some URLs may look like gibberish at first glance, it’s all in the name of efficiency and functionality.

Visiting your favorite website might be nearly impossible without URL encoding, which converts URLs into a syntax that web browsers can interpret. So, the next time you come across an encoded URL, remember that it’s carefully formatted to provide a smooth user experience for all.