Make and read UUIDs and ULIDs IDENT
Every backend needs IDs, and the choice is real: v4 is unguessable but sorts randomly; v7 and ULID are time-ordered so they index tidily. Make either, and read back the version and the time an ID carries.
Generate
Decode
How it works
Choosing an ID
Use v4 when the ID must give nothing away and never needs to sort. Use v7 or ULID for primary keys and anything paginated, where being time-ordered keeps a database's index tight, accepting that they reveal their creation time, which IDENT will read back for you. All the randomness here is cryptographic, and nothing is uploaded.
The guides: Does a UUID show when it was made? and What is this timestamp?
Questions people ask about IDENT
What is the difference between UUID v4 and UUID v7?
A v4 UUID is 122 random bits with the version and variant bits set; it carries no information and sorts in no useful order. A v7 UUID, defined in RFC 9562, begins with the Unix time in milliseconds in its first 48 bits and fills the rest with random bits, so IDs made later sort later.
That ordering is why v7 suits database primary keys: new rows go to the end of the index instead of landing at random places in it. The cost is that anyone holding the ID can read when it was made.
What is a ULID?
A 128-bit identifier written as 26 characters of Crockford’s base32: the first 10 hold a 48-bit millisecond timestamp and the last 16 hold 80 random bits. Because the time comes first and the alphabet is in order, ULIDs sort as text in the order they were made. The alphabet leaves out I, L, O and U so that an ID read aloud or typed by hand is less likely to be mistaken.
A ULID and a v7 UUID hold much the same information; which to use usually comes down to what your database and libraries expect.
Can someone tell when a UUID was created?
For the time-based kinds, yes. Paste one into Decode and the timestamp it carries is shown in UTC: v1 and v6 count 100-nanosecond intervals from 15 October 1582, and v7 and ULID count milliseconds from 1970. A v1 UUID was also traditionally built from the machine’s network card address.
A v4 UUID carries no time at all, so use v4 where the creation time must not be given away.
Are v7 UUIDs or ULIDs made in the same millisecond in order?
Not from this page. IDs made in the same millisecond share the timestamp and differ only in their random bits, so among themselves they sort in random order. When you generate a batch, most of it falls in the same few milliseconds. Some libraries add a counter so that IDs from one millisecond still sort in the order they were made; if your code depends on that, generate the IDs there.
What do the version and variant of a UUID mean?
The version is the first hex digit of the third group, so in xxxxxxxx-xxxx-7xxx-xxxx-xxxxxxxxxxxx it is 7. It says how the rest was made: 1 and 6 from time, 3 and 5 by hashing a name, 4 at random, 7 from Unix time, 8 by a custom layout.
The variant is in the top bits of the first digit of the fourth group. For every UUID made under RFC 4122 or RFC 9562 that digit is 8, 9, a or b. The all-zero nil UUID shows as version 0 with the legacy NCS variant, which is what its bits say.
How many can I generate at once, and how random are they?
From 1 to 1,000 at a time, one per line, ready to copy. The random bits come from the browser’s cryptographic generator, crypto.getRandomValues, not from Math.random, so they are fit for IDs that must not be guessed.
What formats can Decode read?
A UUID in the usual 36-character form, 8-4-4-4-12 hex digits with hyphens, in upper or lower case, and a 26-character ULID in either case. Braces, a urn:uuid: prefix and 32 hex digits without hyphens are not recognised, so remove them first. A ULID that has been retyped with I, L or O in it is refused rather than corrected. So is one whose first character is above 7, since its time would not fit in 48 bits.
Doing this often? OBSCURA Umbra edits a folder of code where it is and runs JavaScript, TypeScript and Python in a sandbox. Everything is US$5 a month or US$48 a year.