Build a URL Shortener with n8n and Airtable
Why Build Your Own URL Shortener?
If you share links a lot, you already know the pain of long, messy URLs. They look ugly, they are hard to paste in chats or slides, and tracking clicks can be a headache. That is where a simple URL shortener comes in handy.
Instead of relying only on third-party tools like bit.ly, you can actually build your own lightweight URL shortener with n8n and Airtable. It is surprisingly straightforward, and you get full control over:
- How your short links look
- What data you store about them
- How you track and visualize clicks
In this guide, we will walk through an n8n workflow template that turns your Airtable base into a mini link management system. It creates short URLs, saves them with metadata, tracks every click, and even gives you a simple dashboard for analytics.
What This n8n + Airtable URL Shortener Actually Does
Let us start with the big picture. The workflow is built around three webhook endpoints, each handling a different part of the job:
- Create short URLs from long ones, store them in Airtable, and return a clean short link.
- Redirect users from the short URL to the original URL while tracking clicks.
- Show a dashboard with stats like total links, total clicks, and unique hosts.
Think of it as your own tiny link shortener service, powered by n8n automation and Airtable integration.
When Should You Use This Workflow?
This template is great if you:
- Share links in newsletters, social posts, or internal docs and want basic analytics
- Already use Airtable and like keeping data in one place
- Want a simple, self-hosted alternative to public URL shorteners
- Are exploring n8n automation and want a practical, real-world project
If you have ever wondered, “Can I just spin up my own shortener without writing a full app?”, this workflow is exactly that.
How the Workflow Is Structured
The n8n template is split into three main flows, each triggered by a different webhook:
- URL Shortening Flow – handles new URLs and generates short IDs.
- Redirection and Click Tracking Flow – redirects and logs clicks.
- Dashboard Flow – pulls stats and renders a simple HTML dashboard.
Let us walk through each one in a friendly, step-by-step way.
1. URL Shortening Flow
This is the part you will hit when you want to turn a long URL into a short one. It is triggered by a webhook endpoint and then runs through several nodes.
Step-by-step breakdown
- Webhook Node
The flow starts with a webhook that accepts aGETrequest. It expects a query parameter calledurl, which is the long URL you want to shorten.
Example:/sh?url=https://example.com/very/long/link - Check URL
Next, the workflow checks whether theurlparameter is actually present. If it is missing, the workflow returns a friendly error message instead of trying to process an empty value. - Extract URL
Once validation passes, the long URL is extracted from the query string so the rest of the flow can work with it cleanly. - Crypto Hash
To generate a consistent and unique identifier, the workflow uses a Crypto node with theSHA256algorithm. It hashes the original long URL so that the same URL will always produce the same hash. - Set Short ID
From that long SHA256 hash, the workflow takes the first 6 characters and uses that as the short ID. This short ID is combined with your base URL to form the full short URL.
In this step, the flow also prepares fields like:id– the 6-character short identifierlongUrl– the original URLshortUrl– the final short link format
- Find in Airtable
Before creating a new record, the workflow checks Airtable to see if that short ID already exists. This prevents duplicate entries if the same long URL is shortened multiple times. - Already Exists?
If Airtable returns a match, the workflow simply responds with the existing short URL. No new record is added, and you get a stable, repeatable short link for the same long URL. - Append New Record
If no existing record is found, the workflow:- Sets the initial
clickscount to 0 - Saves the
id,longUrl,shortUrl, andhost(the domain part) - Appends a new row in your Airtable base
- Sets the initial
- Response
Finally, the workflow returns a response with the generated short URL so you can use it in your app, emails, or anywhere else.
2. Redirection and Click Tracking Flow
Now that you can generate short links, you need a way to handle what happens when someone actually clicks one. That is where the redirect flow comes in.
How the redirect logic works
- Webhook for Redirect
This flow is triggered by a different webhook endpoint, which expects anidquery parameter.
Example:/go?id=abc123
Here,abc123is the short ID created earlier. - Find by ID in Airtable
The workflow looks up the record in Airtable where theidmatches the one from the query. If it finds a match, it pulls out the storedlongUrland related details. - Exists Check
If a record exists for that ID, the flow continues. If not, the workflow returns a 404-style response that indicates the short link was not found. - Update Click Count
For valid IDs, the workflow increments theclicksfield by 1 in Airtable. This is your basic click tracking logic, so every visit is recorded. - Redirect Response
Instead of directly sending an HTTP redirect, the workflow returns a small HTML page that includes JavaScript. That JavaScript automatically redirects the user to the originallongUrl.
The result is seamless for the user, while still giving you full control over tracking.
3. Dashboard Flow
Click tracking is useful, but it is even better when you can see everything at a glance. The dashboard flow turns your Airtable data into a simple HTML analytics view.
What the dashboard shows
- Webhook for Dashboard
This third webhook does not need any query parameters. You just hit the endpoint directly, like/dashboard. - Retrieve All Records
The workflow fetches all records from your Airtable base that store the links and their stats. - Extract Stats Function
A function node then processes those records to calculate:- Total number of shortened links
- Total clicks across all links
- Number of unique hosts (domains)
- Set Dashboard
Finally, the flow builds an HTML dashboard with some basic styling. It displays your aggregate stats in a clean layout that you can open in a browser.
You can treat it as a starting point and customize the HTML or styling to match your own branding.
How to Set Everything Up
Ready to try it out? Here is how to get the URL shortener workflow running with n8n and Airtable.
1. Prepare your Airtable base
Create a new Airtable base with these columns:
id– short identifier (6-character code)longUrl– the original full URLshortUrl– the generated short linkclicks– number of times the link has been usedhost– the host/domain extracted from the long URL
2. Get your Airtable credentials
- Find or generate your Airtable API key
- Locate your Airtable base ID
You will need both to connect n8n to Airtable.
3. Configure Airtable nodes in n8n
In the n8n workflow, update the Airtable nodes with your:
- API key
- Base ID
- Table name that holds your URL records
4. Deploy the webhooks
Set up and deploy the workflow with three webhook endpoints, for example:
/sh– for URL creation and shortening/go– for redirection and click tracking/dashboard– for the analytics dashboard
5. Test your URL shortener
- Send a long URL to the
/shendpoint as a query parameter, like:/sh?url=https://example.com/my/long/link - Take the short URL returned by the workflow.
- Open the short URL using the redirect endpoint, for example:
/go?id=yourShortId - Visit
/dashboardto see your total links, clicks, and hosts.
Why This Workflow Makes Your Life Easier
Instead of juggling multiple tools, you get:
- Centralized data in Airtable, with all URLs and stats in one place
- Automation with n8n, so the whole process runs hands-free
- Customizable logic, since you can tweak nodes, add filters, or extend the dashboard
- Simple click tracking that you can later connect to other workflows or reports
Want to add tagging, user ownership, or advanced analytics later? You already have the foundation in place.
SEO Keywords
URL shortener, click tracking, Airtable integration, n8n automation, URL hash generation, dashboard analytics, link redirection service
Ready To Try It?
If you have been looking for a practical n8n automation project, this is a great one to start with. You will end up with your own URL shortener, click tracking, and a simple analytics dashboard, all powered by n8n and Airtable.
Spin it up, experiment with the workflow, and then customize it to match how you actually use links in your day-to-day work.
