Python

URL Shortener

Nowadays people pay a lot of attention to how things look, that is why sometimes, websites make use of a URL Shortener, to make their website’s URL more presentable. Now, there are many ways one can achieve this shortening. There are several in-built functions available, and there are even hosted websites that offer you a platform to shorten your URL.

Read more..


We have all come across certain articles which have a large URL pasted in it, and it ruins the aesthetics of the entire webpage. This is where URL shorteners can be used to make the web-page more presentable. This time around we will be taking a look at how to build a simple URL shortener using Python.

Project Description

URL Shorteners help website owners reduce the length of their unique web-page address, making it easier to share the website on various platforms. This because extremely crucial in cases where there is a limitation on the number of characters that can be sent, like in a text message or social media post. Long URLs that haven’t been shortened when cut leads to error in loading the webpage and the entire reason for pasting the URL gets nullified. In such cases, people can make use of such shorteners to trim their URLs and make them within the specified restrictions.

Concepts Used

  • Logical Analysis
  • Algorithm Representation
  • Bitwise manipulation
  • Abstraction concepts
  • Python Fundamentals
  • Database Management
  • Flash Fundamentals

Latest projects on Python

Want to develop practical skills on Python? Checkout our latest projects and start learning for free


Components Required

  1. A suitable OS such as Windows/Linux/Mac
  2. Python 2 or upwards installed
  3. Python module that supports shortening must be installed, such as pyshorteners
  4. Base62 Encoder/Decoder
  5. Flask
  6. SQLite3

Advantages of URL shortening

  • Easier to remember URL
  • Easier to share URL
  • Easier to maintain the URL
  • Easier to post on social media
  • Can be used even when there are restrictions on the number of characters

Project Implementation

  1. URL shortening requires two things:
  • A String mapping algorithm that will allow you to map long strings to make them into short strings using Base 62
  • A simple web framework such as Flask or Tornado that pints the URL you created towards the actual URL.

How to build Python projects Did you know

Skyfi Labs helps students learn practical skills by building real-world projects.

You can enrol with friends and receive kits at your doorstep

You can learn from experts, build working projects, showcase skills to the world and grab the best jobs.
Get started today!


  1. Create a database that stores the actual URL of the website.
  2. Now, allocate a Primary Key to all these URLs.
  3. Create an algorithm that generates a string when a PK is passed to it.
  4. Next, use a mapper to map that string created to the original URL stored in the database.
  5. In this process, we are not actually reducing the string size, but rather abstracting the actual string to make it look shorter.
  6. Once you have mapped the URL onto a smaller string, pass that URL onto the user.
  7. You can also define an option to allow the user to input the URL, so as to gain input and add that URL to the database created.
  8. Anytime someone sends out a request for that URL through your shortened version, it will look up the mapped original URL, and redirect the webpage there so that you open to the right site.
  9. Use a Base62 algorithm to convert a large number of strings into a smaller-sized one. A Base62 Encoder makes the URL smaller, while a Decoder may be used to map the short one to the long one, enabling users to access the right website when needed.
  10. If you are using older versions of Python, you might need to install or import the following libraries:
  • import contextlib
  • parse import urlencode
  • urllib import urlencode
  • request import urlopen
  • urllib2 import urlopen
  • import sys
  1. Python libraries use bit-shuffling to prevent generating predictable URLs.
  2. The number of digits and alphabets are completely random in such libraries, and they use mall-case characters by default.
  3. They usually employ a prime number of digits and characters to increase the efficiency of the algorithm.
Kit required to develop URL Shortener:
Technologies you will learn by working on URL Shortener:
URL Shortener
Skyfi Labs Last Updated: 2021-07-05





Join 250,000+ students from 36+ countries & develop practical skills by building projects

Get kits shipped in 24 hours. Build using online tutorials.

More Project Ideas on Python

Face recognition using Raspberry Pi
Linux Based Medication remainder
Ultrasonic beats player
Automated door opener with lighting control
IoT based theft detection using Raspberry Pi
Wheelchair wih safety system
Raspberry Pi osilloscope
Health monitoring using Raspberry pi
Automatic Green house system
Wheel combined robotic suspension system
Bank Account Management System using SQL and C++
Content Aggregation Project using Python
URL Shortener
Develop An Expense Tracking System using Python
Mp3 Player using Python
Simple Chat room using Python
Folder sorter according to files extensions using Python
Batch Image editor using Python
Password Generator and Manager using Python
Web Scrapper (Amazon Price Tracker)
Bird Species detection using Python
Develop An Online CV Builder using Python
Online Job Portal using Python and SQL database
Social Media Site using Python (Django)
Driver Drowsiness detection using Python
Traffic recognition using python
Website Blocker using python
Speech Emotion Recognition using Python
Speed Typing test with Python
Gender and Age Detection using Python
Pharmacy management using Python
Virtual Notebook - Python project
Find My Professor
How to Develop a TIC TAC TOE game using Python
Admission tracking system
Assignment submission system using Python
Smart feedback system using Python
Data collection tool using Python
Language translator and converter using Python
Automatic Brand LOGO detection using Python
Rock, paper, scissor game using python
Youtube video downloader with Tkinter UI python project
Instagram bot using python
Desktop notifier app using python
Spotify song downloader using python
Jarvis Personal assistant using Python
Sound processing python project
Develop a Supermarket Billing System with Python
Desktop voice assistant project

Subscribe to receive more project ideas

Stay up-to-date and build projects on latest technologies