DevBox

Your daily dose of essential developer utilities.

UUID / GUID Generator
Generate and format various versions of universally unique identifiers.
About UUIDs / GUIDs

What is a GUID?

GUID (aka UUID) is an acronym for 'Globally Unique Identifier' (or 'Universally Unique Identifier'). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID is used commonly used elsewhere.

Understanding UUID Versions

  • Version 1: Generated from a timestamp and a node ID (typically the MAC address). They are time-based and reveal when it was created.
  • Version 4: Generated from purely random or pseudo-random numbers. This is the most common version used when uniqueness is the primary concern.
  • Version 7: A newer, time-based version that combines a Unix timestamp with random bits. They are lexicographically sortable by creation time, making them excellent for database primary keys.
  • Nil UUID: A special UUID of all zeros (00000000-0000-0000-0000-000000000000), which acts as a null value.

Use cases for generating UUIDs

Here are some common use cases for generating a version 4 UUID:

  • Database Records: Version 4 UUIDs can be used as unique identifiers for records in databases. They ensure that each record has a unique identifier without relying on sequential numbers or other potentially conflicting identifiers.
  • Distributed Systems: In distributed systems where multiple nodes or processes operate independently, version 4 UUIDs can be used to generate unique identifiers for events, transactions, or messages. This allows different components to operate autonomously and later correlate events based on their unique identifiers.
  • Web Applications: Version 4 UUIDs can be used as unique identifiers for various entities in web applications. For example, they can be assigned to user accounts, session IDs, or resources like images, files, or documents.
  • Message Queues: When messages are passed between different components or services through a message queue system, version 4 UUIDs can be used as unique message IDs. This helps track and identify messages as they move through the system.
  • Testing and Development: Version 4 UUIDs are often used in testing and development environments as placeholder or mock identifiers when creating test data or simulating scenarios.
  • Security and Authentication: Version 4 UUIDs can be used in security-related scenarios such as generating secure tokens, session IDs, or API keys.
  • Logging and Tracking: Version 4 UUIDs can be used as unique identifiers for log entries, trace information, or audit trails, facilitating debugging and troubleshooting.

How are GUIDs used?

GUIDs are used by enterprise software developers, progammers, engineers, database administrators, and testers in systems and application development and testing. They are used in Java, C#, Python, C++, SQL databases, and non-relational Cloud databases as primary keys, versions, component identifiers, or just about anywhere else a truly unique identifier is required.

How unique is a GUID?

128-bits is big enough and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%. Or if every human on Earth generated 600,000,000 GUIDs there would only be a 50% probability of a duplicate.

UUID Frequently Asked Questions

What is a UUID?

A UUID (Universally Unique Identifier) is a string of characters that is used to uniquely identify an object. You may also see the term GUID (Globally Unique Identifier) which is also commonly used. Both UUIDs and GUIDs are generated according to a standard, using a combination of random numbers, timestamps and algorithms, all of which makes it extremely unlikely that two values will be equal. It is based on the RFC 4122 standard.

What version UUID generator is this tool?

This UUID generator generates a version 4 universally unique identifier. A version 4 UUID is made up of 32 hexadecimal characters (128 bits), divided into five groups separated by hyphens in this format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. You may also see this written as 8-4-4-4-12.

Why generate UUID version 4?

The main advantage of version 4 UUIDs is that they are generated using random numbers, which makes it extremely unlikely that two UUIDs will be the same.

How unlikely? To be specific, a UUID is 16 bytes or 128 bits. Out of these 128 bits, 4 are used to indicate the version, and another 2 indicate the variant. This leaves us with 122 bits, and as a result we have 2^122 possible combinations, or 5.3 undecillion, or 5.31x10^36 (or a 5 with 36 zeros behind it). That is a lot. When we begin talking about numbers in this range - the probability that a duplicate value will be generated is essentially zero.

One way to think about a version 4 UUID collision is like this: Only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%. Or, to put it another way, the probability of one duplicate would be about 50% if every person on earth owned 600 million UUIDs.

How does FusionAuth use UUIDs?

In FusionAuth, UUIDs are used to identify users, applications, and other objects such as roles and groups. For example, when a new user or role is created, a UUID is generated and assigned to that user or role. This UUID can then be used to uniquely identify the user within the system, grant them appropriate resources, and it is used as a primary key in the database to store and retrieve user information. For almost every resource, FusionAuth can either generate a UUID on creation or use one supplied to the API, allowing for easier migrations of existing users, roles and other entities.