What is URL encoding?

Feb 20, 2024 · 2 min read

Have you ever noticed odd characters like %20 or %40 in a web address and wondered what was going on? This is called URL encoding, and it allows URLs to contain characters that normally wouldn't be allowed or would break things.

Why Use URL Encoding?

URLs can only contain certain alphanumeric characters and symbols. Spaces, accented letters, and non-Latin scripts like Cyrillic or Chinese cannot normally appear in a URL. To get around this, URL encoding converts these characters into a % symbol followed by two hexadecimal digits that represent that character's encoding in ASCII or UTF-8.

For example, a space is converted to %20. Here are some other common encodings:

Space = %20
! = %21
$ = %24
& = %26
+ = %2B
@ = %40
é = %C3%A9

This allows URLs to contain special characters while still being valid links that won't break.

When is URL Encoding Used?

The most common use case for URL encoding is encoding user-submitted data in URLs, such as search queries or form data.

For example, if a user searches for where is the louvre?, the space needs to be converted to %20 to allow that query string to be passed in the URL:

https://www.example.com/search?query=where%20is%20the%20louvre?

URL encoding also allows non-Latin characters and emojis to be included in URLs.

Encoding/Decoding Tools

There are many online tools available to encode or decode URL encoded text. Developers can programmatically encode parameters using libraries like urllib in Python. Most web frameworks have methods to handle URL encoding as well.

The main thing is that URL encoding makes URLs more flexible and interoperable by expanding the allowable characters. It converts URLs into a common format that browsers and servers can parse. So next time you see %20, know that it's not gibberish, just a space in disguise!

Browse by tags:

Browse by language:

The easiest way to do Web Scraping

Get HTML from any page with a simple API call. We handle proxy rotation, browser identities, automatic retries, CAPTCHAs, JavaScript rendering, etc automatically for you


Try ProxiesAPI for free

curl "http://api.proxiesapi.com/?key=API_KEY&url=https://example.com"

<!doctype html>
<html>
<head>
    <title>Example Domain</title>
    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
...

X

Don't leave just yet!

Enter your email below to claim your free API key: