Nano ID Generator

Your Nano ID—
Length—
Alphabet—
Entropy (bits)—

How Nano ID Generator is calculated: Nano ID = one random character from the chosen alphabet per position. Default: 21 chars from 64 symbols = 126 bits of entropy.

What is a Nano ID generator?

A Nano ID generator makes a short, random, URL-safe identifier — a string like V1StGXR8_Z5jdHi6B-myT that you can use as a database key, a file name, or a token in a link. The default on this page is 21 characters drawn from 64 symbols, which gives 126 bits of entropy. Press the button and a new one appears. Press it again and a different one appears. Every ID is made in your browser, and none of them is ever sent anywhere.

The need is simple: almost everything a developer builds needs unique names for things. A row in a database needs a key. An uploaded file needs a name that will not clash with another upload. A share link needs a token that cannot be guessed. Counting numbers work until two systems write at once, and long UUIDs work but are ugly in a URL. Nano IDs sit in the middle — short, random, and safe to paste anywhere.

This generator covers the choices people actually make: length from 5 to 64 characters, and four alphabets — URL-safe, alphanumeric, lowercase plus digits, and hex. It shows the length, the alphabet, and the entropy in bits, so you can see how strong the ID is instead of guessing. A password generator makes the same kind of randomness for secrets, and this tool makes it for identifiers.

How a Nano ID generator works

The generator picks one character at random for each position, using Math.random in your browser, until the ID is as long as you asked. The default alphabet has 64 symbols: capital A to Z, small a to z, digits 0 to 9, underscore, and hyphen. Every one of those characters is safe in a URL, so the ID never needs encoding and never breaks a link.

Strength is measured in entropy — bits. Entropy is length times log2 of the alphabet size. The default ID is 21 characters from 64 symbols, and log2 of 64 is exactly 6, so 21 × 6 = 126 bits. That is the number shown on this page. The total number of possible default IDs is 64 to the power of 21, which is about 8.5 × 10³⁷ — a number so large that random collisions are, for practical purposes, impossible.

To see the scale, take the collision question seriously for a moment. With 126 bits of randomness, you would need to generate about 9.2 × 10¹⁸ IDs before the chance of even one collision reached 50 percent. Generating a billion IDs every second, that would take roughly 300 years. Your app will not get there. The risk is not zero — randomness never gives zero — but it is far below the risk of a bug in your own code.

Length and alphabet: the two choices that matter

Length is the single biggest factor. Each extra character multiplies the number of possible IDs by the size of the alphabet. Going from 10 characters to 21 does not double the strength — it multiplies the possibilities by 64 to the power of 11. A 10-character hex ID has 40 bits of entropy; a 21-character default ID has 126 bits. If you remember one rule, remember this: longer beats fancier.

The alphabet matters too, and the trade is about where the ID will live. The URL-safe default is the right choice for links, file names, and anything a user might see, because it never needs encoding. Alphanumeric drops the underscore and hyphen, which some systems prefer. Lowercase plus digits is the friendliest for humans to read aloud or type, and it still gives 108.6 bits at 21 characters. Hex gives only 84 bits at 21 characters, but it matches systems that expect hexadecimal strings.

The practical advice is boring and correct: use the 21-character default unless you have a reason not to. It is the size the Nano ID library itself uses, it is short enough to read, and 126 bits is more randomness than a UUID carries. Shorten it only when a real limit forces you to — a short code printed on a card, or a legacy column that holds 10 characters — and never shorten it below 10 for anything that must stay unique.

A worked example: three IDs, three alphabets

Here is a real comparison, using the exact numbers this page shows. First, the default: 21 characters from the 64-symbol URL-safe alphabet. The entropy is 126 bits. That is the ID to use for database keys, upload names, and share links — the general-purpose choice that needs no further thought.

Second, a short hex ID: 10 characters from 16 symbols. The entropy is 40 bits, and the number of possible IDs is 16 to the power of 10, which is about 1.1 × 10¹². That is fine for a temporary code that expires in an hour, but it is far too small for a permanent database key — a busy system could generate enough 10-character hex IDs to risk a collision, and a short ID is also easier to guess.

Third, the human-friendly option: 21 characters from lowercase letters plus digits. The alphabet has 36 symbols, log2 of 36 is about 5.17, and 21 × 5.17 = 108.6 bits of entropy. It is weaker than the default by about 17 bits, but it is much easier to read over the phone, and 108.6 bits is still far more than any real system needs. Pick it when humans will type the ID.

Who uses a Nano ID generator, and why

Web developers are the biggest users. Every record they create needs a key, every upload needs a file name, and every share link needs a token. A Nano ID fits all three jobs: it is unique enough for a database, safe enough for a URL, and short enough to show in an address bar without looking broken.

App developers are the second group. Mobile and desktop apps create records offline and sync them later, so two phones can create two records at the same moment. Counting numbers would clash; random IDs do not. A UUID generator solves the same problem with a longer format, and a random number generator makes the same kind of randomness for test data and one-time codes.

The generator on this page handles all of these uses — pick a length, pick an alphabet, press the button, copy the result — which covers ninety percent of what anyone needs. The one thing it does not do is remember the ID for you. That is your database's job, and the ID is only useful once it is stored next to the thing it names.

Testers and QA engineers are a fourth group, and they use the generator for throwaway data — a fresh user, a fresh order, a fresh session, each with its own ID, so tests never trip over each other. One click gives a new ID, and the next test gets another, with no setup and no cleanup.

Nano ID generator vs UUID generator

A Nano ID and a UUID solve the same problem — a unique name for a thing — and the difference is mostly size and style. A UUID is 36 characters with hyphens and carries 122 bits of randomness. A default Nano ID is 21 characters and carries 126 bits. The Nano ID is shorter and slightly stronger, and it has no hyphens to strip out of a URL.

The UUID has one advantage: it is a standard. Every language has a UUID library, every database has a UUID column type, and every developer recognises one on sight. A UUID generator makes one in the format other systems expect, which matters when you hand IDs to a system you do not control. If your database or your partner's API expects a UUID, use a UUID.

For everything you control yourself, the Nano ID is the better default. It is shorter in a URL, easier to read, and just as unique. And a password generator answers a different need entirely: secrets that must resist guessing, not names that must stay unique. An ID can be public; a password must never be.

Common Nano ID mistakes

The most common mistake is using a Nano ID as a secret. The IDs on this page are made with Math.random in the browser, which is fine for names that must be unique, but it is not a cryptographic random generator. Never use a Nano ID as a password, an API key, or a reset token. For secrets, use a server-side CSPRNG — a cryptographically secure random generator — or a password generator built for that job, and check the result with a password strength checker.

Second: making IDs too short. A 5-character ID from the default alphabet has only 30 bits of entropy, and a busy system will eventually generate the same one twice. Short IDs are fine for codes that expire in minutes. For anything permanent, use 21 characters, and never go below 10.

Third: assuming uniqueness is guaranteed. Randomness makes collisions unlikely, not impossible. Your database should still enforce uniqueness on the ID column, so that the one-in-a-billion collision fails loudly at insert time instead of silently overwriting a record. The generator makes collisions unlikely; the database makes them harmless.

Fourth: putting meaning in the ID. An ID that encodes a date, a user, or a type will leak information and will break when the meaning changes. Let the ID be random and meaningless, and store the meaning in a separate column. Random IDs are also safer in URLs, because nobody can guess the next one by changing a digit.

How to use this Nano ID generator

Using this Nano ID generator is simple. Set the length — 21 is the default, and it is a good choice. Pick an alphabet — URL-safe is the default, and it is the right choice for links and file names. Press Generate Nano ID, and a new ID appears in the box below, with its length, alphabet, and entropy shown above it.

To copy the result, use the Copy button next to the output box. To make another one, press the button again — every press makes a fresh ID. If the ID looks too long for your use, shorten it to 12 or 16 characters, but remember that shorter means weaker, and check the entropy number before you settle.

Everything runs in your browser. No sign-up, no account, no data sent anywhere — the ID never leaves your device, and it is never stored. It works offline once the page has loaded. One honest limit to remember: these IDs use Math.random, so they are right for unique names and wrong for secrets. For a password or an API key, use a server-side CSPRNG instead. Try it with something real before you need it: generate an ID for your next test record, and see how short and clean it looks in a URL.

Frequently Asked Questions

A Nano ID is a short, random, URL-safe identifier, usually 21 characters from a 64-symbol alphabet. The default ID on this page has 126 bits of entropy, which is slightly more than a UUID's 122 bits, in a much shorter string. Developers use Nano IDs as database keys, file names, and tokens in share links.

Use the 21-character default for anything permanent — database keys, file names, and share links. It gives 126 bits of entropy with the URL-safe alphabet. Shorten it only when a real limit forces you to, and never below 10 characters for anything that must stay unique. A 10-character hex ID has only 40 bits of entropy, which is too weak for a permanent key.

It is unique for practical purposes, not by guarantee. The default 21-character ID has about 8.5 × 10³⁷ possible values, so a collision would take roughly 300 years of generating a billion IDs a second to reach a 50 percent chance. Still, enforce uniqueness in your database, so the rare collision fails loudly instead of overwriting a record.

No. The IDs on this page are made with Math.random in the browser, which is fine for unique names but is not a cryptographic random generator. For passwords, API keys, and reset tokens, use a server-side CSPRNG or a password generator built for secrets. An ID can be public; a secret must never be.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.