UUID Generator

    Generate UUID v1, v4, v5 and ULID in bulk with format options.

    Validate UUID

    Advertisement

    What Are UUIDs?

    UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify information in computer systems. Defined by RFC 4122, UUIDs are formatted as 32 hexadecimal digits in 5 groups separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. They were designed to be generated independently across distributed systems without coordination, making them ideal for databases, APIs, and microservices where central ID assignment is impractical.

    UUID v1 vs v4 vs v5

    UUID v1 is time-based — it encodes the timestamp and MAC address, making it sortable but potentially leaking information. UUID v4 is purely random, generated using cryptographic randomness — the most commonly used version for its simplicity and privacy. UUID v5 is name-based, using SHA-1 hashing of a namespace and name to produce deterministic, reproducible UUIDs. Use v4 for most cases, v1 when you need sorting, and v5 when you need deterministic IDs from input data.

    UUID Collision Probability

    UUID v4 has 122 random bits, yielding 5.3 × 10^36 possible values. To have a 50% probability of a collision, you'd need to generate about 2.7 × 10^18 (2.7 quintillion) UUIDs. For perspective, generating 1 billion UUIDs per second would take 86 years to reach that number. In practice, UUID v4 collisions are so unlikely they can be treated as impossible for any real-world application.

    ULIDs: Sortable Alternative

    ULID (Universally Unique Lexicographically Sortable Identifier) addresses UUID's main limitation: lack of natural sorting. ULIDs encode the timestamp in the first 10 characters and randomness in the remaining 16, creating IDs that are chronologically sortable as strings. This makes them ideal for database primary keys where you want both uniqueness and temporal ordering without additional indexes.

    UUIDs in Databases

    PostgreSQL has a native UUID type with indexing support. MySQL can use BINARY(16) or CHAR(36). MongoDB's ObjectId is similar in concept but only 96 bits. Using UUIDs as primary keys avoids sequential ID enumeration attacks and simplifies database merging, but they can impact index performance due to their randomness. UUID v7 (newer) addresses this by incorporating timestamps for better index locality.

    Frequently Asked Questions

    Advertisement