About NanoID

NanoID is a tiny, secure, URL-friendly, unique string ID generator for JavaScript. It is designed to be a modern replacement for UUIDs, offering similar uniqueness guarantees in a much more compact format.

Why NanoID?

  • Small. 108 bytes (minified and gzipped). No dependencies. Control the size of the ID.
  • Safe. It uses hardware random generator. Can be used in clusters.
  • URL Friendly. Uses A-Za-z0-9_- symbols.

NanoID vs UUID

FeatureNanoIDUUID v4
Size21 chars36 chars
Alphabet64 symbols16 (Hex)
SpeedFasterFast

Randomness & Collisions

The standard NanoID uses an alphabet of 64 characters (A-Z, a-z, 0-9, - and _). With a default length of 21 characters, there are 64^21 possible combinations. That is roughly 85 undecillion IDs.

How safe is it?

If you generate 1,000 IDs per second, it would take approximately 456 million years to have a 1% probability of at least one collision.

To match the randomness of a UUID (which has 122 random bits), a NanoID only needs to be length 21.