Are GUIDs actually unique?


This could potentially be the shortest blog post ever written, and the short mathematically accurate answer is “no”. A GUID (globally unique identifier) is a 32 character sequence of  alphanumeric (letters or numbers). They are useful to developers because, in theory when generated, no GUID like this has been generated before, nor will another be generated again.

However, for anyone who understands what “always forever” means in math, this should immediately ring false. There is a limit to the number of GUIDs that can be generated. However, that limit has a very high ceiling, and that’s what is so fascinating about them.

Bear with me through a little math for a moment. GUIDs are generated using 6 fixed bits and 122 random bits1. The fixed bits contain the version of the GUID generation algorithm being used, and previously contained the machines MAC address (though this was changed as it exposed a privacy hole where one could locate the machine a GUID was generated at). This means there are 2^122, or 5.2 x 10^361, or about 5 trillion trillion trillion unique GUIDs.

Statistically, it’s a very safe assumption to expect that a generated GUID is totally unique across all systems for all time, which blows my mind. You are being provided something seemingly mathematically impossible. Something (almost) unique, but something that we can tangibly touch and view, within the confines of just 32 alphanumeric characters.

I like to think that every time I programmatically generate a GUID that I’m going to some giant reservoir at the center of the Universe that contains all GUIDs and stealing one. However, emptying this reservoir would actually be more feeble than going to the ocean2 and trying to empty it by taking out one droplet water at a time (mathematically actually, about 200 trillion times as feeble, since by size comparison every drop of water in the ocean would represent 200 trillion GUIDs).

Every once in awhile I stare at a list of generated test data containing GUIDs in a bit of awe. I feel a slight sense of loss when deleting that test data knowing the likelihood of any one of those exact GUIDs being generated is less likely than winning the lotto 6/49 jackpot 5 times in a row3. So I commend you to all, developer or not, to respect the GUID. It is a way of glimpsing at a tiny corner of infinity, which even in this reduced format is quite a phenomenon to ponder.

Want to take one away from the universe?
You already have (refresh the page to take more):



Stack overflow for some initial inspiration, here

1 ^
2 ^ Calculated using the oceans volume from
3 ^ Calculated using the probability referenced at

Leave a Reply

Your email address will not be published. Required fields are marked *