MiServe DevTools

Your lid

Pin tools here. They are saved in this browser.

UUID, ULID & Nano ID Generator

Generate UUID v4, time-ordered UUID v7, ULIDs and Nano IDs in bulk, and read the version and timestamp inside an ID.

Type
Variant
Timestamp (UTC)
Your local time
Unix time in milliseconds

Runs in your browser. Nothing you paste is uploaded.

About this tool

Which ID to choose

UUID version 4 is 122 random bits. It tells nothing about when or where it was made, and it is the usual choice when an ID only has to be unique. UUID version 7, standardised in RFC 9562 in 2024, puts a 48-bit Unix timestamp in milliseconds in front of 74 random bits. New IDs sort after older ones, so rows inserted together stay together in a database index, at the price of showing the creation time to anyone who sees the ID.

A ULID follows the same idea with a different spelling: 48 bits of time and 80 random bits in 26 case-insensitive characters of Crockford Base32, without hyphens. A Nano ID is a random string whose length and alphabet you choose. The default of 21 characters from 64 URL-safe symbols carries 126 bits, a little more than a version 4 UUID, in a shorter string.

How unique, and how secret

Random IDs can collide in theory. For version 4 you would have to generate about 2.7 quintillion (2.7 × 10^18) UUIDs before the chance of a single repeat reaches one half, which is why applications treat them as unique. A shorter Nano ID or a small alphabet lowers that margin: the line under the options shows how many random bits your choice gives.

An ID is an identifier, not a secret. Versions 1, 6 and 7 and ULIDs reveal when they were made, and RFC 9562 warns against relying on a UUID as proof of permission. For a password reset link, a session or an API key, use a random token of at least 128 bits and keep only a hash of it on the server.

Reading a UUID

In the usual form xxxxxxxx-xxxx-Vxxx-Nxxx-xxxxxxxxxxxx, the digit V is the version and the first bits of N are the variant: 8, 9, a or b for the RFC 9562 layout that almost every UUID uses. Versions 1 and 6 hold a 60-bit count of 100-nanosecond steps since 15 October 1582 together with a node ID, which was originally the network card's MAC address. Version 7 holds Unix milliseconds. Versions 3 and 5 are hashes of a name and version 4 is random, so they contain nothing to decode.

A ULID's first ten characters are its timestamp. The inspector also accepts UUIDs without hyphens, in braces or with the urn:uuid: prefix.

How this tool generates them

Every random bit comes from crypto.getRandomValues, the browser's cryptographic random number generator. Nothing is requested from a server and nothing is stored.

Version 7 UUIDs made in the same millisecond keep the timestamp and add a random step to the 74 random bits, which is the monotonic method described in RFC 9562, so a batch always sorts in the order it was generated. ULIDs made in the same millisecond add one to the random part, as the ULID specification describes. That order holds for IDs from this page. IDs made on different machines in the same millisecond sort in no particular order. Nano ID characters are picked by discarding random bytes that fall outside the alphabet, so every symbol is equally likely.

Questions

Should I use UUID v4 or UUID v7 as a database primary key?

Version 7 is the better fit for a primary key when you want new rows to land next to each other in the index and you do not mind that the ID shows its creation time. Version 4 is the choice when the ID must reveal nothing. Both are 128 bits and fit the same uuid column.

Can two generated UUIDs be the same?

It is possible but far too unlikely to plan for. A version 4 UUID has 122 random bits, so about 2.7 quintillion (2.7 × 10^18) of them are needed before a single repeat becomes as likely as not. The real risk is a weak random source, which is why this tool uses the browser's cryptographic generator.

Is a ULID the same as a UUID v7?

No, but the two are similar. Both are 128 bits and start with a 48-bit timestamp in milliseconds, so the bits of a ULID fit in a 128-bit UUID column. A ULID has no version and variant fields, so RFC 9562 does not define it as a UUID, and its text form uses Crockford Base32 where a UUID uses hexadecimal.

Can I tell when a UUID was created?

Yes for UUID versions 1, 6 and 7 and for ULIDs, which carry a timestamp. Paste the value into the inspector to see it as a date. A version 4 UUID is random and holds no time.

More in Hashing