Random Generators

Five generators sharing one engine. What separates them is the shape of the answer and who reads it.

Last updated 5 tools

Which one do you want?

All five draw from the same source and the same rejection-sampling code, so none is more random than another. The question is never "which is strongest" — it is what the output has to look like, and who or what is going to read it.

If you needUseLooks like
One long value for a machine to consumeRandom StringUNvnWaXPLYZz…
One character at a time, read aloudRandom Characterq
A batch of codes a customer will redeemRandom CodeA7K9-P2XM-4RTV
An identifier that must be unique everywhereUUID8f14e45f-ceea-…
Digits behind an attempt limitPIN810938

Why the shape decides it

A random string and a random character come from the same function. What differs is that a string is copied as one value and a character is read out, so one is a line of text and the other is a large tile you can see from across a room.

A redemption code goes further: it will be typed by hand off a printed card, so it is grouped in fours, avoids the characters people misread, and can carry a check character that catches a typo before you look it up.

The two that are not really about randomness

A UUID is sized so that nobody ever has to coordinate — 122 random bits means two systems can generate identifiers forever without checking with each other. Uniqueness, not unguessability, is the job.

A PIN is the opposite extreme: short enough to type on a keypad, and safe only because something counts the wrong answers. Its page reports the odds under a three-try lockout rather than a strength band, because that is what actually decides the outcome.

One engine, five interfaces

Every value on these pages comes from crypto.getRandomValues() through rejection sampling, which is what stops the first letters of the alphabet coming up about 11% more often than the last four. Math.random() is never used.

Sharing the engine means a correctness fix reaches all five at once. The interfaces stay separate because a teacher drawing a letter and a developer seeding a test fixture want different things from the same arithmetic.

All 5 tools