Skip to content

UUID Generator - Create Version 1 and Version 4 UUIDs

Generate Version 1 (time-based) and Version 4 (random) UUIDs online. This free tool explains the UUID format, formula, and use cases for database keys and APIs.

UUID Generator

UUID Version
Generated UUID
Loading calculator...
📚

Documentation

UUID Generator

A UUID generator is a tool that creates a Universally Unique Identifier, or UUID: a 128-bit code used to label a piece of data so that no other item, anywhere, is likely to share the same label. This page generates Version 1 (time-based) and Version 4 (random) UUIDs.

What is a UUID?

A UUID is a 128-bit number written as 32 hexadecimal digits (the characters 0–9 and a-f). It is split into five groups separated by hyphens, in the pattern 8-4-4-4-12, for 36 characters in total. An example UUID looks like this:

1550e8400-e29b-41d4-a716-446655440000
2

UUIDs are defined by RFC 9562, published by the Internet Engineering Task Force in May 2024, which replaced the older RFC 4122 from 2005. Both documents describe the same 128-bit format. Software uses them to identify database rows, files, user sessions, and other records without needing a central authority to hand out numbers. Because the space of possible UUIDs is so large, two computers can generate UUIDs independently, at the same moment, and almost never produce the same one.

UUID format and structure

The 128 bits of a UUID are split into named fields. Each field takes up a fixed number of bits:

  • time_low - 32 bits
  • time_mid - 16 bits
  • time_hi_and_version - 16 bits
  • clock_seq_hi_and_reserved - 8 bits
  • clock_seq_low - 8 bits
  • node - 48 bits
UUID field layout time_low time_mid time_hi seq_hi seq_lo node time_low: 32 bits time_mid: 16 bits time_hi_and_version: 16 bits clock_seq_hi_and_reserved: 8 bits clock_seq_low: 8 bits node: 48 bits

Four bits inside time_hi_and_version hold the UUID's version number, and two bits inside clock_seq_hi_and_reserved hold the variant, which tells software how to read the rest of the fields. Eight versions are defined.

The field names above come from Version 1, where they really do hold a time and a node value. Other versions keep the same 8-4-4-4-12 layout and the same field boundaries, but fill most of the bits with random data. In a Version 4 UUID the group labelled time_low is random, not a time.

How to generate a UUID with this tool

  1. Pick a version: Version 1 (time-based) or Version 4 (random).
  2. Read the UUID from the result box. A new one appears as soon as the page loads or the version changes.
  3. Select "Generate" for another one.
  4. Select "Copy" to copy the result to the clipboard, then paste it into code, a database, or a configuration file.

The panel below the result splits the UUID into its five fields and names each one, so the version digit and the variant digit are easy to find.

Version 4 suits most jobs, including database keys and session tokens, because it carries no information about when or where it was made. Version 1 suits records whose creation time needs to be recoverable from the identifier itself, such as log entries.

UUID version 1 vs version 4

Version 1 encodes the current timestamp, plus a randomly chosen clock sequence and node value. The standard allows the node value to be a computer's real network (MAC) address, but it also allows a randomly generated node value as a privacy-preserving alternative. This tool always uses the random option: its Version 1 UUIDs never read or expose a real MAC address. The standard also requires the lowest bit of the node field's first byte to be set to 1 on a random node value, and this tool sets it. Real network cards never have that bit set, so a random node can never be mistaken for a real one. That is why the second hex digit of the fifth group is always odd in a Version 1 UUID from this page: 1, 3, 5, 7, 9, b, d, or f.

The timestamp inside a Version 1 UUID can be read back, so records can be put in creation order. Sorting the UUID text itself does not do that, because the first group holds the lowest 32 bits of the timestamp, which wrap about every 7 minutes. Version 6, added in RFC 9562, stores the same timestamp with the highest bits first so that plain text sorting works.

Version 4 is built from random bits, with a few bits fixed to mark the version and variant. It carries no timestamp and no machine-specific data, so it reveals nothing about when or where it was created. It is not sortable by creation order.

Six other versions exist in the standard but are not generated by this tool: Version 2 (DCE Security, rarely used); Version 3 and Version 5, built by hashing a namespace and a name with MD5 or SHA-1, so the same input always produces the same UUID; and Versions 6, 7, and 8, added by RFC 9562 in 2024 for sortable and custom identifiers.

How to calculate a UUID (formula)

Version 4:

  1. Generate 128 random bits.
  2. Set the four version bits, the first hex digit of the third group, to 0100 (hex 4).
  3. Set the top two bits of the fourth group to 10 (so the first hex digit of that group is 8, 9, a, or b).

Only 122 of the 128 bits are actually random, since 6 bits are fixed by steps 2 and 3. That gives 2^122, or about 5.3 × 10^36, possible Version 4 UUIDs.

Version 1:

  1. Take the current time as a count of 100-nanosecond intervals since October 15, 1582, the date of the Gregorian calendar reform. In practice that is the ordinary Unix time in milliseconds plus 12,219,292,800,000, all multiplied by 10,000.
  2. Split that 60-bit count across three fields: the lowest 32 bits go in time_low, the next 16 in time_mid, and the top 12 in time_hi_and_version.
  3. Generate a 14-bit clock sequence, used to avoid collisions if the system clock is set backward.
  4. Generate a 48-bit node value, with the lowest bit of its first byte set to 1.
  5. Set the version bits to 0001 and the variant bits to 10.

Across all UUID versions, the full 128-bit space holds 2^128, or about 3.4 × 10^38, possible values. That count is so large that random collisions are not a practical concern.

Worked example

Reading a Version 4 UUID. Take the example from earlier: 550e8400-e29b-41d4-a716-446655440000.

  • Third group, 41d4: the first digit is 4, marking this as a Version 4 UUID.
  • Fourth group, a716: the first digit, a (binary 1010), starts with 10, the required variant bits.
  • The remaining hex digits are the random payload.

A program reading this UUID checks the 4 and the 10 pattern to confirm the format, then treats the rest as an opaque random value.

Building a Version 1 UUID. Suppose the clock reads 1,700,000,000,000 milliseconds of Unix time, which is 14 November 2023, 22:13:20 UTC.

  1. Add the offset: 1,700,000,000,000 + 12,219,292,800,000 = 13,919,292,800,000 ms.
  2. Multiply by 10,000 to get 100-nanosecond intervals: 139,192,928,000,000,000. In hexadecimal that is 01EE833B04AFC000.
  3. Slice it: time_low = 04AFC000 (lowest 8 hex digits), time_mid = 833B (next 4), and the top 12 bits are 1EE.
  4. Put the version digit 1 in front of 1EE, giving time_hi_and_version = 11EE.

The UUID then reads 04afc000-833b-11ee- followed by the clock sequence and the node value. Software can reverse these four steps to recover 14 November 2023 from the identifier.

Common uses for UUIDs

  • Primary keys in databases, especially when multiple servers create records at the same time without checking in with each other.
  • Session tokens and API keys, usually Version 4 for the privacy it provides.
  • Identifiers for files, events, and resources in distributed systems such as microservices.
  • Device IDs in large IoT networks, where each device can generate its own ID offline.

The main trade-off is size: a UUID takes 16 bytes of storage, compared with 4 or 8 bytes for a simple integer counter, and some databases index UUIDs more slowly than sequential integers.

Alternatives to UUIDs

Auto-incrementing integers are smaller and simpler but do not work well once more than one server needs to hand out IDs independently. Snowflake IDs, developed at Twitter, combine a timestamp with a worker ID to produce compact, sortable identifiers across a distributed system. ULIDs (Universally Unique Lexicographically Sortable Identifiers) are a newer format designed to be both random and sortable by creation time, unlike a standard Version 4 UUID.

History of the UUID standard

The UUID concept began in the 1980s at Apollo Computer, as part of its Network Computing System. The Open Software Foundation later adopted the format for its Distributed Computing Environment. The Internet Engineering Task Force published RFC 4122 in 2005, and replaced it with RFC 9562 in May 2024. RFC 9562 keeps every earlier version working unchanged and adds Versions 6, 7, and 8.

Frequently asked questions

What is a UUID generator used for? It creates unique identifiers for databases, distributed systems, session tokens, API keys, and device IDs, so that no two records need to share the same identifier.

What is the difference between UUID v1 and v4? Version 1 encodes a timestamp that software can read back to recover the creation time. Version 4 is fully random and carries no timestamp. This tool's Version 1 output uses a randomly generated node value rather than a real MAC address, so it does not expose machine-identifying information either.

Does Version 1 expose my MAC address? Not with this tool. The standard allows a Version 1 UUID's node field to hold a real MAC address, but this generator always fills that field with random bits and sets the bit that marks the value as not a real network address.

Are UUIDs guaranteed to be unique? No identifier scheme can guarantee absolute uniqueness, but the 128-bit space holds about 3.4 × 10^38 possible values, and a Version 4 UUID has about 5.3 × 10^36 possible random values. The chance of a duplicate is small enough to ignore for almost any practical use.

Can I use a UUID as a database primary key? Yes. UUIDs work well as primary keys in distributed systems because any node can generate one without checking with a central server. The cost is 16 bytes of storage per key, more than a typical integer, and potentially slower index performance on very large tables.

Is a UUID the same as a GUID? Yes. GUID (Globally Unique Identifier) is Microsoft's name for the same concept defined by RFC 4122 as a UUID.

Can Version 4 UUIDs be sorted by creation time? No. Version 4 UUIDs are random, so they carry no record of when they were created. A Version 1 UUID does carry one, but it has to be decoded first; sorting the text does not give creation order. Version 6, Version 7, and ULIDs are designed to sort directly as text.

References

  1. Davis, K., Peabody, B., & Leach, P. (2024). Universally Unique IDentifiers (UUIDs). RFC 9562. https://www.rfc-editor.org/rfc/rfc9562
  2. Leach, P., Mealling, M., & Salz, R. (2005). A Universally Unique IDentifier (UUID) URN Namespace. RFC 4122. https://www.rfc-editor.org/rfc/rfc4122
  3. Universally unique identifier. In Wikipedia. https://en.wikipedia.org/wiki/Universally_unique_identifier
  4. Snowflake ID. In Wikipedia. https://en.wikipedia.org/wiki/Snowflake_ID
  5. ULID Spec. GitHub. https://github.com/ulid/spec