Random String & Nano ID Generator

Make random strings, Nano IDs, codes and API keys from any alphabet, with a strength and collision estimate.

Runs in your browser. Nothing is uploaded.

    How to use the Random String & Nano ID Generator

    1. Choose which characters to use, such as the Nano ID alphabet, letters and numbers, hexadecimal, numbers only or your own set.
    2. Set the length and how many strings you need. Optionally add a prefix like sk_ or split the string with dashes.
    3. Tick Leave out look-alikes if people will read or type the codes by hand.
    4. Check the strength summary, then copy the list or download it as a text file.

    Random strings for every job

    Developers need random strings all the time: short IDs for URLs, invitation and coupon codes, licence keys, test data, file names, API keys and secrets. Each job has different needs. A URL ID should be short and safe to paste; a code read over the phone should avoid characters that look alike; a secret token needs enough randomness that nobody can guess it.

    Choose the characters

    • Nano ID: 64 URL-safe characters (A–Z a–z 0–9 _ -). At 21 characters you get IDs as unique as a UUID in a much shorter form.
    • Letters and numbers: safe almost everywhere, including file names and databases.
    • Hexadecimal: for values that are later read as bytes, such as keys and salts.
    • Numbers only: for PINs and verification codes.
    • Custom: type any set of characters, including symbols or non-Latin letters.

    Leaving out look-alikes removes 0, O, 1, l and I, so codes copied from paper or a phone call come back right the first time.

    How strong is it?

    Every character adds randomness equal to log₂ of the alphabet size, so the strength summary shows the total in bits. Around 128 bits is plenty for secrets; IDs that only need to be unique can be shorter. The tool also estimates how many strings you can create before a duplicate becomes a real risk (1%). If you need millions of IDs, choose a length where that number is far above your total.

    Fair, unbiased characters

    A common mistake is to take a random byte and use the remainder after dividing by the alphabet size. With an alphabet of 62 characters, the first 8 characters then appear more often. This generator masks each random byte to the nearest power of two and simply skips values that fall outside the alphabet, so every character has exactly the same chance.

    Private and offline

    All strings are made with crypto.getRandomValues on your device. Nothing is uploaded, and the page keeps working without a connection. For standard-format IDs, see the UUID Generator.

    Frequently asked questions

    Is this a Nano ID generator?

    Yes. With the Nano ID alphabet and length 21 you get IDs in the same format as the popular nanoid library, with the same 126 bits of randomness. Other lengths and alphabets work like nanoid’s customAlphabet.

    Are the strings random enough for passwords and API keys?

    They come from your browser’s cryptographic random generator, and every character is equally likely. Aim for at least 128 bits, shown in the strength summary: for example 22 characters from letters and numbers. For memorable passwords, use the Password Generator.

    Why not just use Math.random?

    Math.random is not designed to be unpredictable, and the common trick of taking a random number modulo the alphabet size makes some characters more likely than others. This tool uses crypto.getRandomValues and throws away values that would cause bias.

    What does the duplicate estimate mean?

    It is the number of strings you could create before there is a 1% chance that any two are the same, from the birthday problem. Short codes collide sooner than people expect: six digits reach 1% after only about 140 codes.

    Is anything sent to a server?

    No. Strings are generated on your device and never leave the page.

    Tutorials