Nano ID Generator

Generate compact, URL-safe Nano IDs with custom length and alphabet.

Free Nano ID generator — create short, URL-safe, cryptographically random IDs with a custom length and alphabet. Runs entirely in your browser, nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is a Nano ID?

Nano ID is a tiny, URL-safe unique-ID format. By default it is 21 characters from a 64-symbol alphabet, giving collision odds comparable to a UUID v4 in a more compact, copy-friendly string.

Nano ID is a compact, URL-safe unique-ID format that is widely used as a shorter alternative to UUIDs for database primary keys, short links, session tokens, filenames, and API identifiers. This generator produces Nano IDs entirely in your browser with the length, count, and alphabet you specify.

How it works

Each character is chosen from your alphabet using rejection sampling — the same unbiased technique used by the reference nanoid JavaScript library. The generator computes the smallest power-of-two bitmask that covers the alphabet size, draws cryptographically random bytes from crypto.getRandomValues, masks each byte, and discards any value that falls outside the valid alphabet range before re-drawing. This eliminates modulo bias — a common flaw in naive implementations where characters near the beginning of the alphabet appear slightly more often than others.

The default alphabet is the 64-symbol URL-safe set (A–Z, a–z, 0–9, _, -), and the default length is 21 characters, producing collision resistance comparable to a UUID v4 in roughly 60% fewer characters.

Nano ID vs. UUID v4

UUID v4Nano ID (default)
Length36 characters21 characters
Character sethex + hyphens64 URL-safe chars
URL-safeNo (hyphens OK, but verbose)Yes, no encoding needed
Collision resistance~2¹²²~2¹²⁶
Randomness sourceDepends on implementationWeb Crypto API

Nano IDs are shorter and drop straight into URLs, filenames, and database keys without percent-encoding. UUIDs have the advantage of being universally recognisable and parseable by existing tooling that specifically expects the UUID format.

Customising the alphabet

Hex-style IDs: set the alphabet to 0123456789abcdef and length to 16 for compact hex identifiers — for example a3f90c1b7e2d8f45. Useful when downstream systems expect hex.

Numeric-only codes: set the alphabet to 0123456789 for short numeric codes — note that a 6-digit code from 10 symbols has far fewer possibilities than a 6-character ID from 64 symbols, so lengthen accordingly if collision matters.

Ambiguity-free: remove look-alike characters (0, O, I, l, 1) from the alphabet for codes that users may need to read and type back, such as short activation codes or vouchers.

Shorter IDs for low-volume apps: 12 characters from the 64-symbol alphabet is safe for most applications that will never generate more than a few million records. Test the collision odds against your expected ID count before going below 12.

Everything runs in your browser. The random bytes, your custom alphabet, and all generated IDs never leave your device.