How does Spotify codes work if the design is so simple?


If you don’t know what I’m talking about it’s this [here]( People can draw them on paper and they still work. They seem to work well and are very simplistic. And there are over 50 millions songs on Spotify, and infinite playlists. How does this work?

In: Technology

There are over 20 lines of varying sizes in one of those. You can arrange 20 things in over 2 quintillion ways (2 followed by 18 zeroes).

Spotify has a long way to go before they run out of codes. If they do, they can just add another line in the code, and now they have 3 more quintillion codes.

Edit: yes I was too lazy to count the actual number of lines.

There are 23 bars, that can have 8 different sizes. The first and last bar are always the smallest size, and the middle bar is always the largest size (this is done for calibration). That leaves 20 ‘information’ bars with 8 possibilities each, which can have 8^20 unique combinations.

This is the patent:

From the patent, here’s basically what happens. There are identifying marks in the code that let the software figure out the relative size of each bar. The tallest bar is in the middle, and the leftmost and rightmost bar are the shortest. Then, the other bars are ranked from 0 to 7 on how tall they are in relation to the references.

It seems like Spotify is using 23 bars as standard, but the patent notes these can be arbitrarily large. Currently, that leaves us with 8^20 different combinations. A parsed code looks like: 53526254731226474112

This is actually tiny when dealing with URLs. For example, that is not enough to encode the URL “”. The patent refers to using a random number or index counter that is associated on the server with the code. Essentially, this means that somewhere, there is a massive table that contains all the codes generated and links them to what they are supposed to refer you to.

Note: This sounds really inefficient because there’s a table running out there with at least 50 million code-song pairs, and more likely billions because of profiles, playlists, etc. In actuality, there are very efficient ways of dealing with this problem, and while billions sounds like a lot, on an enterprise scale, it’s minuscule.