Dev tools

ULID generator

ULID generator, random IDs from crypto.getRandomValues, nothing is uploaded.

Runs on your device. The file is never uploaded.

ULID generator writes 20 characters of Crockford base32: ten for the millisecond the system clock reports, ten drawn from crypto.getRandomValues. Text order is time order, because the timestamp leads. Two made in the same millisecond order at random, because there is no monotonic counter, and the specification's 26-character form has six more random characters.

Options

Questions

What does a generated ULID look like?

20 characters of uppercase Crockford base32. The first 10 encode the current millisecond from the system clock, and the remaining 10 are random. Note that this is shorter than the 26-character ULID in the original specification, which uses 16 random characters where this one uses 10.

Which alphabet is used?

Crockford base32: 0123456789ABCDEFGHJKMNPQRSTVWXYZ. I, L, O and U are left out, so an I cannot be misread as a 1 or an O as a 0 when someone copies an ID off a screen or reads it aloud. Output is uppercase only, with no hyphens or padding.

Do they sort by time?

Yes, at millisecond resolution. The timestamp is the leading part of the string and base32 preserves ordering, so sorting the IDs as text sorts them by creation time. Within a single millisecond the order is random: there is no monotonic counter here, so two IDs made in the same millisecond can sort either way.

Is the random part biased?

No. Each random character is one byte reduced modulo 32, and 256 is an exact multiple of 32, so every character in the alphabet is equally likely. The bytes come from crypto.getRandomValues, the browser cryptographic source, rather than from Math.random.

How does a ULID compare to a UUID?

It is shorter, sortable and easier to read back, where a UUID v4 is 36 characters with hyphens and carries no time at all. This implementation has 10 random characters, so it holds less randomness than a v4 UUID. Use it where sortable identifiers help, not where you need something unguessable.

How many can I generate at once?

Between 1 and 1000, set by count, which starts at 5. They are printed one per line in the order they were made, so a batch already comes out in timestamp order. Anything outside the range is refused with "count must be a whole number between 1 and 1000".

Related Dev tools