If you've used the internet, you've also used a URL shortener, even if you weren't aware of it. URL shorteners provide a convenient way of sharing web addresses. But do you know how they work?

There are two main parts to URL shortening. The first involves taking an original URL and generating a shorter one. The second is the reverse process: turning a short URL back into the original one.

How Generating a Shorter URL Works

A URL shortener takes a URL and generates a shorter one, of around 10 characters. The shorter URL is unique and redirects users to the full address of the original URL automatically. But, how does the generator do this?

To generate a short URL, you begin by entering a URL on the shortener's web page. That URL gets sent to the server, which validates it and checks for code injections and invalid parameters.

Related: Ways to Quickly Shorten URLs Straight From Your Browser

At this point, the server stores the longer URL in a database. It then generates a unique hash code and returns it in the form of a short URL. Hashing is a process that maps data of any size to a fixed-size output. This enables a shortener to guarantee the longest length of its short URLs.

What Happens When You Click on a Short URL?

The short URL acts as a key that maps to the original URL. When you try to open a short URL, your browser sends an HTTP request to the shortener server.

An illustration of a hand pointing to abstract text on a computer screen surrounded by icons

The service looks for this short URL in its database. If the resource exists, the web server fetches the original, longer URL and redirects to it. If it doesn't recognize the short URL, the server will redirect to an error page typically a 404.

Related: You Can Now Shorten Form URLs in Microsoft Forms

Using a Shorter URL Is Better

Long URLs take up a lot of characters. So sharing them in resumes, emails, and microblogging sites like Twitter can be inconvenient. Shortening a lengthy URL makes the link easier to share. Advertizers often use short URLs in print material.

However, that's not all! URL shorteners often provide extra features such as usage tracking so you can see how well your link is performing.