NanoID Generator

Generate URL-safe NanoIDs.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Generate a NanoID: a compact random identifier built from the characters A-Z, a-z, 0-9, underscore and hyphen, so it is safe in URLs and filenames. The web tool starts at 16 characters, and you can change the length.

How to use

1
Step 1
Set the length (the tool starts at 16).
2
Step 2
Press Generate.
3
Step 3
Copy the ID.

How it works

NanoID picks each character at random from a 64-symbol alphabet using the browser's secure random generator. Each character adds 6 bits of randomness, so a 16-character ID has 96 bits, while a 21-character ID (the library default) has 126 bits, similar to a UUID v4.

Worked example

A 16-character ID

Input
Length 16
Output
lLiIzTbhi8jzJ722
Walkthrough
16 characters at 6 bits each is 96 bits of randomness. Each click returns a new value.

Limitations

  • The alphabet cannot be customised here.
  • Use 21 characters if you want collision resistance comparable to a UUID.
  • Characters such as l, I and 1 can look alike, so the IDs are not ideal for reading aloud.

Questions

What is a NanoID?
A short, URL-safe random ID. It is a smaller alternative to a UUID.
How long should a NanoID be?
21 characters matches the library default and gives about the same collision resistance as UUID v4.
NanoID or UUID?
Choose NanoID for shorter URLs and slugs. Choose UUID when a system or database expects the UUID format.
Is a NanoID secure enough for a token?
It uses a secure random source, but for session or API tokens prefer a purpose-built generator with at least 128 bits.

Features

  • URL-safe alphabet
  • Adjustable length
  • Secure random source

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • TypeScript in 100 Seconds

    Fireship

    Typed JS snippets often get formatted or hashed nearby.

    Watch on YouTube
  • Inspect Network Activity - Chrome DevTools 101

    Chrome for Developers

    Debugging payloads you paste into JSON and JWT tools.

    Watch on YouTube
  • web.dev

    Google

    Modern web guidance that pairs with encoding and tooling pages.

  • Regular expressions

    MDN

    JS regex guide aligned with browser-based testers.