Skip to tool
ecech.
💻 Developer & Code

Choose an ID Length From Collision Risk, Not From How Short It Looks

Generate cryptographically strong local IDs with a custom alphabet while measuring entropy, address space and birthday-bound collision risk.

Entropy per ID

Alphabet size

Possible IDs

Collision probability

Generator

Web Crypto

Generated samples

Advertisement

How the calculation works

Alphabet64 symbolsLength21 charactersEntropy126 bitsEvery extra character multiplies the address space by the alphabet size.

How to Use This Tool

Short random IDs trade storage and readability against collision risk. The useful question is not whether a ten-character ID looks random; it is how many possible IDs exist and how many records will compete for that space. This page reports both entropy and the birthday-bound probability for your expected count.

Uniform selection matters

A common custom generator takes a random byte modulo the alphabet length. When 256 is not evenly divisible by that length, some symbols occur more often than others. The samples here reject out-of-range bytes before mapping them, preserving a uniform distribution, and use the browser's cryptographically strong random source rather than Math.random.

8 chars12 chars21 chars
Length increases space exponentially; record count increases collision opportunities roughly with its square.

Uniqueness still belongs in the database

A negligible probability is not a uniqueness guarantee. Keep a unique index on the identifier and retry generation if insertion reports a collision. Random public IDs also should not replace authorization: an unguessable-looking URL is not permission to read the record behind it.

Sources & assumptions

Tool Spec v2 · verified 2026-08-18. Platform rules and fees can change; the editable inputs remain authoritative for your account.

Official references

Model assumptions

  • Collision probability assumes every character is selected independently and uniformly from the entered unique ASCII alphabet.
  • The birthday-bound estimate models accidental random collisions, not hostile guessing or leakage of identifiers.
Advertisement

Frequently Asked Questions

What is Nano ID's default size?
The official Nano ID project uses a 21-character URL-friendly ID by default, providing about 126 random bits with its 64-symbol alphabet.
How is collision probability estimated?
For small probabilities it uses the birthday approximation n(n−1)/(2N), where n is generated IDs and N is the total address space.
Why reject some random bytes?
Modulo mapping is biased unless the alphabet size divides 256. Rejection sampling discards the uneven remainder so each symbol has the same chance.
Can I use emoji in the alphabet?
This implementation deliberately accepts unique ASCII characters only. JavaScript string length and Unicode grapheme handling can otherwise disagree about what one symbol means.
Does a low collision probability guarantee unique IDs?
No. Enforce a unique database constraint and retry on conflict. Probability guides sizing but does not replace the constraint.
Are generated IDs sent anywhere?
No. The samples use Web Crypto in your browser and are never transmitted by this static page.

Related tools in Developer & Code

Browse all Developer & Code tools
The Mac mini the ecech. site is built on, beside a handwritten note reading ecech.com.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.