Back to projects

Experiment Experiment 2026

URL compressor

Four openings, seven endings, and twenty six popular destinations, agreed in advance and reduced to single characters. What is left of an address afterwards is the part that identifies the thing.

A terminal window showing the compressor turning a forty three character video address into twelve characters.

Almost every web address you type begins with one of four openings and ends with one of about seven endings. Between them that is up to sixteen characters of pure ceremony, repeated by everybody, all day, on a channel where the cost of a character is real.

Text messages, radio, printed material, a URL read out over a phone: there are still places where an address has to be short enough to survive being copied by a human. The interesting question is not how to shorten a link with a server, which is a solved and slightly boring problem. It is how much shorter an address gets with no server at all.

Twenty eight combinations and twenty six letters

The four openings and the seven endings make twenty eight pairs. Each pair gets a number, so the whole scaffolding of an address collapses into a single digit or two, and what remains is the domain body and the path. An address becomes something like 1.example/pricing.

On top of that sits a second table of twenty six popular destinations, one per letter of the alphabet, each covering a full prefix rather than a domain. The letter y stands in for the whole of a video watch address up to the identifier, w for an encyclopedia article path, r for a forum’s subsection path. When one of those matches, the prefix stops being characters at all and becomes one keystroke.

What the numbers actually were

A forty three character video link came out at twelve characters, a saving of seventy two percent. A forty one character encyclopedia article came out at twelve as well, seventy one percent. Both of those are cases where the single letter table does the heavy lifting.

The ordinary case is more honest. A thirty one character address on an unremarkable dot com came out at seventeen characters, forty five percent, purely from folding the opening and the ending into one digit. That is a large saving for a table that fits on one screen and a program that does no lookups.

Where it stops, which is the interesting part

Point it at an address whose ending is not one of the seven, and nothing happens at all. A documentation link on a newer domain ending came back uncompressed, because the scheme has no entry for it and refuses to guess. The compression is entirely a function of how well the table predicts the input.

That is the oldest trade in the field, made visible in about two hundred lines of Python: you buy space with assumptions, and you keep buying until the assumptions stop holding. It is a compression scheme rather than a link shortener, so the output travels between two parties who share the table and resolves in no browser anywhere. Growing the table would compress more addresses and would also mean both ends carrying a bigger dictionary for the privilege.

The general shape holds well beyond web addresses. Any format that repeats the same fixed strings on every message is storing convention, and convention is the cheapest thing in the world to agree on in advance.

Want something like this?

Tell us what the finished thing should do and roughly when you need it. You get a straight answer about scope and price.