Guides — practical notes on UUIDv7, ULID, NanoID and KSUID
Five notes, from choosing a format to calculating collision risk.
- UUIDv4 vs UUIDv7: which one, and whenBit layout, sorting habits, index impact and the pitfalls of monotonic mode, compared for real systems.
- ULID structure: why 26 characters sort by timeThe 48-bit timestamp, 80 random bits, Crockford Base32, monotonic ULIDs and the details that trip people up.
- NanoID: designing entropy with alphabet and lengthHow the default 64-character alphabet and 21 characters produce 126 bits, where short IDs become risky, and the traps in custom alphabets.
- KSUID: the 2014 epoch and 27 Base62 charactersFour bytes of epoch seconds, a 128-bit payload, Base62 ordering, and how KSUID compares with ULID and UUIDv7.
- Calculating ID collision risk with the birthday paradoxThe collision formula, IDs needed per bit width, and the real numbers for 1,000 IDs per second over ten years.