Skip to the content.


URLShortener Logo
A Free And Simple URL Shortener

Table of Contents


When sites like and are present, why would you want to build a custom short URL? Especially when they offer analytics?

For one, they are insanely expensive. for example offers a basic plan at $29/month. Which is a lot.

This is a completely free to use and simple tool that lets you create Short Url Links for your custom Domains.


This module is distributed via npm packet manager, which is contained within node and should be installed as one of your project’s devDependencies:

npm install --save-dev netlify-shortener


  1. Create a GitHub Repository and initialize it with a _redirects file.

This _redirects file should contain links to all the websites for which you want to create a short URL in the below format :

/go          #Custom URL
/gh          #Custom URL

/*   #Default Link

You can now modify the contents of your “_redirects” file to create your own custom link.

  1. Create an account on netlify. Log in and select “New site from Git”. Select GitHub and give it permissions to access your GitHub repository. Now, choose the GitHub repository that you created earlier and click on deploy.

  2. Click on your site and navigate to domain settings. Here, choose your custom domain. You can either buy a new one or create a short netlify domain for free.

Netlify will automatically deploy the result when you push to this repository.

Once you are done with this. You can manually create your own short URL by editing the contents of _redirects file.

Following the above example,       #should open       #should open

However, you can also automate this with a few simple steps.

  1. Go to your working directory(Your repository), and in your terminal type : npm init -y

This should create a package.json file.

  1. In your terminal enter :

    npm install --save-dev netlify-shortener

And this should add netlify-shortener to your node_modules.

  1. You will have to edit your package.json file to include netlify-shortener in scripts and modify your baseURL
  "baseUrl": "",     #Modify to use your custom address.
  "scripts": {
    "shorten": "netlify-shortener"          #Add netlify-shortener to scripts.

You are all set and ready to go.

Open your terminal and run this :

npm run shorten                         # simply formats your _redirects file
npm run shorten yh    # adds yh as a short URL for you. 

If you have finished the above steps, should lead you to Youtube.

The netlify-shortener does a few things:

  1. adds the URL to the top of _redirects
  2. runs a git commit and push (this will trigger netlify to deploy your new redirect)
  3. Copies the short URL to your clipboard


To contribute to URLShortener, fork the repository, create a new branch and send us a pull request. Make sure you read before sending us Pull requests.

Also, thanks for contributing to Open-source!


URLShortener is under The MIT License. Read the LICENSE file for more information.