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 an Internet Engineering Task Force standard. The first version of that standard, RFC 4122, was published in July 2005. It was replaced in May 2024 by RFC 9562, which obsoletes RFC 4122 and adds new versions. Software uses UUIDs to identify database rows, files, 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 mark the UUID's version number, and two bits inside clock_seq_hi_and_reserved mark the variant, which tells software how to read the rest of the fields.

How to generate a UUID with this tool

  1. Pick a version: Version 1 (time-based) or Version 4 (random).
  2. Select "Generate." The tool builds a new 128-bit UUID immediately.
  3. Select "Copy" to copy the result to the clipboard.
  4. Paste the UUID into code, a database, or a configuration file.

Version 4 suits most jobs, such as database keys, because it carries no information about when or where it was made. Version 1 records the time it was made, which can help when you want to know when a record was created.

UUID version 1 vs version 4

Version 1 encodes the current timestamp, plus a clock sequence and a node value. The original standard let the node value be a computer's real network (MAC) address. The newer standard says MAC addresses pose privacy risks and should not be used, and allows a random node value instead. This tool always uses random bits for the node, so its Version 1 UUIDs never read or expose a real MAC address. As the standard requires for a random node, the tool sets the least significant bit of the node's first octet (the multicast bit) to 1, which marks the node as random rather than a real network address. The tool's clock reads the time in milliseconds, so the smallest steps of the timestamp are always zero.

Version 1 UUIDs do not sort by creation time as text. The fastest-changing part of the timestamp, time_low, comes first, so a later UUID can sort before an earlier one. RFC 9562 adds Version 6, a reordered form of Version 1 for better database ordering, and says new systems should use Version 7 instead of Versions 1 and 6 where possible.

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.

Other versions exist in the standard but are not generated by this tool. Version 2 is reserved for DCE Security. Versions 3 and 5 are built by hashing a namespace and a name with MD5 or SHA-1, so the same input always produces the same UUID. Versions 6, 7 and 8 were added by RFC 9562.

How to calculate a UUID (formula)

Version 4:

  1. Generate 128 random bits. The tool gets these bits from the Web Crypto API (crypto.getRandomValues), a cryptographically secure source; only if that API is missing does it fall back to Math.random.
  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 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 15 October 1582, the date of the Gregorian calendar reform. This fills time_low, time_mid, and part of time_hi_and_version.
  2. Generate a random 14-bit clock sequence, used to avoid duplicates if the system clock is set backward.
  3. Generate a random 48-bit node value, then set the multicast bit (the least significant bit of its first byte) to 1. The clock sequence and node come from the same Web Crypto draw as Version 4, with the same Math.random fallback.
  4. 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.

Worked example

Take the example UUID 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 value.

Common uses for UUIDs

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

UUIDs should not be used as passwords, session secrets, or API keys. The standard says implementations must not use UUIDs as security capabilities, meaning an ID that grants access just by being known.

The main trade-off is size: a UUID takes 16 bytes of storage, compared with 4 or 8 bytes for a simple integer counter. Random UUIDs such as Version 4 also have poor database-index locality: new values land at random places in the index, which can slow down inserts.

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. Several time-ordered ID schemes were built to fix the sorting problem, and RFC 9562 lists them as background, including Twitter's Snowflake and ULID. A ULID is 128 bits, like a UUID, and is lexicographically sortable, meaning it sorts in creation order as text. For new systems, UUID Version 7 offers the same benefit inside the UUID standard.

History of the UUID standard

UUIDs were first used in the Apollo Network Computing System, then in the Open Software Foundation's Distributed Computing Environment, and then in Microsoft Windows. The Internet Engineering Task Force published RFC 4122 in July 2005 and replaced it with RFC 9562 in May 2024.

Frequently asked questions

What is a UUID generator used for? It creates unique identifiers for databases, distributed systems, 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. Version 4 is random apart from its version and variant bits, and carries no timestamp. This tool's Version 1 output uses a random node value rather than a real MAC address, so it does not expose machine-identifying information.

Does Version 1 expose my MAC address? Not with this tool. The original standard allowed a Version 1 UUID's node field to hold a real MAC address, but this generator always fills that field with random bits instead, with the multicast bit set to mark it as random.

Are UUIDs guaranteed to be unique? No identifier scheme can guarantee absolute uniqueness, but 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, as long as the random numbers are good.

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 and, for random versions, slower inserts on very large tables.

Is a UUID the same as a GUID? Yes. RFC 9562 says UUIDs are also known as GUIDs (Globally Unique IDentifiers), the name used on Microsoft platforms.

Can Version 1 or Version 4 UUIDs be sorted by creation time? Not as text. Version 4 is random, and Version 1 puts the fastest-changing part of its timestamp first. For IDs that sort in creation order, use UUID Version 7 or a ULID.

References

  1. Internet Engineering Task Force. RFC 9562: Universally Unique IDentifiers (UUIDs). RFC 9562 — obsoletes RFC 4122 (May 2024); 122 random bits in Version 4; Versions 6 and 7 and the advice to prefer Version 7; MAC addresses should not be used; UUIDs must not be security capabilities; poor index locality of Version 4; Apollo NCS, OSF DCE and Microsoft history; GUID as another name.
  2. Internet Engineering Task Force. RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace. RFC 4122 — published July 2005; Version 1 timestamp counts 100-nanosecond intervals since 15 October 1582.
  3. ULID project. Universally Unique Lexicographically Sortable Identifier. ULID specification — 128-bit compatibility with UUID and lexicographic sorting.