How to Build a URL Shortener With Node.js and MongoDB

In this post, we’ll show you how to build a URL shortening service like or using Express.js (Node.js) and MongoDB. Here’s a demo of the final product we’ll be building through our MongoDB hosting platform.
How Does a URL Shortener Work?
At a very high level, the URL shortener works by taking an entered URL and creating a relatively shortened version simplified into an easy to share format. The shortened hash will be generated by base-encoding an auto-incremented counter and creates a minimum three-character hash that increases as the number of stored URLs go up.