Algorithmic Twitter URL shortener
CSS PHP ApacheConf
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
shorten.php is an algorithmic URL shortener for Twitter URLs.

Given a full URL to a tweet such as, this can be shortened to When the short URL is requested, it is algorithmically expanded to a URL. Since the shortening is done algorithmically, no database is needed, and the requirements for running this code are very small.

Try it Now!


The base 10 tweet ID is converted to a NewBase60 number to compress it. The ID is appended to "" forming the shortened URL for the tweet.


To un-shorten a link, the NewBase60 number is converted back to its base 10 equivalent. The base 10 ID is appended to "". This takes advantage of a feature of where they will redirect a tweet URL to the correct username.


Q: Why do I need this?

A: You probably don't

Q: Where is this used?

A: You can see an example of where this is useful on the IRC logs for the #indiewebcamp IRC channel.


Copyright 2013 by Aaron Parecki

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.