Generate a NanoID

Generate a compact random ID from a URL-safe alphabet.

freeworks offlinenothing uploaded
ToolNanoID Generator
Input
Output

How it works

Cryptographically strong random bytes are mapped to the selected alphabet with rejection sampling, producing the requested length. The default alphabet avoids characters that need URL escaping.

  • Twenty-one characters balance compactness and collision resistance.
  • Alphabet and length remain explicit because they change the ID space.

Worked example

Default NanoID
Generate a 21-character NanoID with the default alphabet
Input
											Length: 21
Count: 1
Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-
										
Output
												Bisas68L0xcyRld2iBRQj
											

When to use this

Temporary client records, URL slugs, and public database keys generate Nano IDs.

Edge cases

  • A custom alphabet changes collision probability.
  • Reducing the character count shrinks the available combinations sharply.
  • Random output is not authorization without access control.

References