ULID & NanoID Generator

Generate batches of modern unique IDs — sortable ULIDs or URL-safe NanoIDs

Settings

26-character Crockford base32 ID with a 48-bit millisecond timestamp prefix. Lexicographically sortable.

Generated IDs

No IDs yet

Click Generate to create a batch

Examples

Generate 10 ULIDs for database rows

import { ulid } from "ulid"

const ids = Array.from({ length: 10 }, () => ulid())
// '01HXYZ4K8P0000000000000000'  ← sortable by creation time

ULIDs are 26 characters, lexicographically sortable, and safe to use as primary keys in databases that support string IDs.

NanoID with custom alphabet for readable tokens

import { customAlphabet } from "nanoid"

const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', 12)
const token = nanoid() // e.g. 'A3K9FZ2MQ8RT'

A custom alphabet of uppercase letters and digits produces human-readable tokens free of ambiguous characters, perfect for invite codes or short IDs.

Details

ULID (Universally Unique Lexicographically Sortable Identifier) encodes a 48-bit millisecond timestamp plus 80 random bits into 26 Crockford base32 characters. Unlike UUID v4, ULIDs sort chronologically by default, making them ideal for database primary keys. NanoID is a tiny, secure, URL-friendly unique string ID library. Its default 21-character output uses an alphabet of 64 URL-safe characters and provides a collision probability comparable to UUID v4. Both run entirely in your browser — no data leaves your device.

Examples

Illustrative ULID

Input
Type: ULID
Timestamp supplied to verification command: 1700000000000 ms
Output
01HF7YAT00TWAYTK10A9E7F2YR

Illustrative generated value: 26 uppercase Crockford base32 characters. The timestamp prefix is repeatable for the fixed time, while the random suffix changes every run.

Illustrative default NanoID

Input
Type: NanoID
Size: 21
Alphabet: default URL-safe alphabet
Output
6ZGH_DOk-cpRPMDX5W7Vx

Illustrative generated value. A new 21-character URL-safe ID is produced every run.

Illustrative numeric NanoID

Input
Type: NanoID
Size: 12
Custom alphabet: 0123456789
Output
148546636027

Illustrative generated value. The custom alphabet restricts every character to a decimal digit, but the output changes every run.

About this tool

ULID (Universally Unique Lexicographically Sortable Identifier) fixes a key shortcoming of UUID v4: random IDs produce random index keys that fragment database pages over time. A ULID encodes the current Unix time in milliseconds into the first 10 of its 26 Crockford base32 characters, then appends 80 random bits — making it monotonically sortable and collision-resistant with no coordination required.

NanoID is a compact, URL-safe alternative to UUID. Its 21-character default uses a 64-character alphabet drawn from the Web Crypto API, producing a collision probability on par with UUID v4 in a string 26% shorter. Both the alphabet and size are configurable: a numeric alphabet creates readable codes; a larger size increases entropy.

Both generators run entirely in your browser using crypto.getRandomValues for entropy, so generation is cryptographically secure and no data leaves your device. Use it to seed test fixtures, populate a local database, or compare the two formats before choosing one.

How to use

  1. Generate a batch of ULIDs

    Select the ULID tab, set the Count slider (1–100), and click Generate. Each ULID is 26 Crockford base32 characters with a timestamp prefix. Use 'Copy all' to copy the batch.

  2. Generate NanoIDs with a custom alphabet

    Select the NanoID tab, set the Size slider (4–36, default 21), and optionally enter a custom alphabet. Leave it blank for the default URL-safe alphabet, then Generate.

  3. Use the IDs in your code

    Install with pnpm add ulid or nanoid, then call ulid()/nanoid() at runtime — never during module init or React render, to avoid server/client mismatches.

Use cases

Generate sortable database identifiers

Use ULIDs when lexicographic ordering by creation time is useful for indexes, logs, or offline-created records.

Create compact URL-safe IDs

Use default NanoIDs for opaque route parameters, share links, and client-generated object keys.

Build constrained test fixtures

Set a custom NanoID size and alphabet to exercise validators for numeric, uppercase-only, or otherwise restricted identifiers.

Seed a local dataset in bulk

Generate up to 100 IDs at once and copy the newline-delimited batch into fixtures or import scripts.

ULID vs NanoID vs UUID

PropertyValue
ULID length26 chars (Crockford base32)
NanoID default length21 chars (URL-safe alphabet)
UUID v4 length36 chars incl. 4 dashes
ULID sortable?Yes — timestamp in most-significant bits
NanoID / UUID v4 sortable?No — fully random
NanoID default alphabetA–Z a–z 0–9 _ - (64 chars, URL-safe)

Common mistakes

Mistake:Using an illustrative ID from documentation as a unique production value.

Fix:Generate a fresh ID at runtime. Published examples are already known and may be reused elsewhere.

Mistake:Assuming ULID lexicographic order is strictly monotonic within the same millisecond.

Fix:The standard generator adds a random suffix; use a monotonic ULID implementation when same-millisecond generation order must be preserved.

Mistake:Choosing a very short NanoID or tiny alphabet without considering collisions.

Fix:Increase the size or alphabet so the identifier space comfortably exceeds the expected number of generated records.

Mistake:Entering a one-character custom alphabet and expecting it to apply.

Fix:The component requires at least two trimmed characters; shorter input falls back to the default URL-safe alphabet.

Frequently asked questions

References & standards