ULID and NanoID Generator

Make IDs for database rows, URLs and test data. A ULID is 26 characters that sort by creation time. A NanoID-style ID is a short random string whose length and characters you choose. Both are generated in your browser with the secure random generator.

How to use the ULID and NanoID Generator

  1. Choose ULID for IDs that sort by time, or Short random ID for compact URLs and codes.
  2. For short IDs, pick an alphabet and a length. The tool shows the bits of randomness.
  3. Choose how many IDs you want and press Generate.
  4. Copy the list. Paste a ULID into the reader to see when it was made.

What a ULID contains

A ULID is 26 characters in Crockford base32, which leaves out the letters I, L, O and U. The first 10 characters hold the time in milliseconds since 1970 as a 48-bit number, and the last 16 characters hold 80 random bits. Because time comes first, ULIDs sort in the order they were made.

Check by hand: the time 1469918176385 ms divided into base32 digits gives 01ARYZ6S41, so any ULID made at that moment starts with those ten characters. That moment is 30 July 2016, 22:36:16 UTC.

How long should a short ID be

The bits of randomness are length x log2(alphabet size). The default alphabet of 64 characters gives 6 bits a character, so 21 characters carry 126 bits. A digits-only ID of 8 characters has only about 26.6 bits.

For n random IDs with b bits, the chance that any two match is about n squared divided by 2 to the power b+1 (the birthday bound). With 26.6 bits, 1,000 IDs already have about a 0.5 percent chance of a clash. The tool shows this chance for 1,000,000 IDs so you can judge the length.

Frequently asked questions

ULID or UUID?

ULIDs are shorter at 26 characters, sort by time and use no dashes. UUIDs are the more widely supported standard. Choose what your database and libraries support.

Can I use a ULID in a URL?

Yes. Crockford base32 uses only letters and digits.

Is a ULID secret?

No. It reveals when it was made. Do not use it as a password or access token.

Are the short IDs the same as the NanoID library?

They follow the same idea, random characters from an alphabet of your choice, and are made here without that library.

Sources

Last reviewed