Random String Generator

Generate secure random strings for passwords, API keys, coupon codes, test data and IDs. Set the length from 1 to 1,024 characters, make up to 1,000 strings at once, use letters and numbers, hexadecimal, URL-safe characters or your own, and leave out look-alike characters. Each string is made with your browser’s cryptographic random generator and never leaves your device.

  • Cryptographically secure
  • Up to 1,024 characters
  • Made on your device
Random strings
    Made on this device
    Strings
    0
    Characters to pick from
    0
    Randomness per string
    0
    Characters in total
    0

    How to generate a random string

    Ten random strings of 16 letters and numbers are ready when the page opens. To change them:

    1. Set the length and count

      Any length from 1 to 1,024 characters, and up to 1,000 strings. The chips set common lengths in one tap.

    2. Choose the characters

      Pick a set under Characters, or My own characters to type exactly which characters to use. Tick Leave out look-alikes for codes people will read or type.

    3. Copy or download

      Each string has its own Copy button. Copy all copies the whole list one per line, comma-separated or space-separated, and Download .txt saves it.

    Example

    A 32-character hexadecimal string, like the ones used for API keys and tokens, has 128 bits of randomness: there are 2¹²⁸ possible strings.

    Character sets

    What each **Characters** setting uses, and how random a 16-character string from it is:

    CharactersUsesHow manyWithout look-alikes16 characters
    Letters and numbersA–Z, a–z, 0–9625695 bits
    Letters onlyA–Z, a–z524891 bits
    Lowercase or uppercase lettersa–z or A–Z262475 bits
    Numbers only0–910853 bits
    Hexadecimal0–9 and a–f (or A–F)161464 bits
    URL-safeA–Z, a–z, 0–9, - and _645896 bits
    Letters, numbers and symbolsThe above plus ! # $ % & ( ) * + - . / : ; < = > ? @ [ ] ^ _ { } ~8882103 bits

    The symbols leave out quotes, the backslash, the backtick and the comma, which often need escaping in code, CSV files and command lines.

    How strong is a random string?

    The randomness of a string, in bits, is its length × log₂(number of characters it’s picked from). Each extra bit doubles the number of guesses an attacker needs.

    LengthLetters and numbers (62)Hexadecimal (16)With symbols (88)
    847 bits32 bits51 bits
    1271 bits48 bits77 bits
    1695 bits64 bits103 bits
    24142 bits96 bits155 bits
    32190 bits128 bits206 bits
    64381 bits256 bits413 bits

    These numbers hold only for strings made at random, like the ones here. A password a person makes up has far less randomness than its length suggests.

    Random strings for passwords, API keys and codes

    • Passwords. Use 16 or more characters from Letters, numbers and symbols, and keep them in a password manager. If a site rejects some symbols, switch to Letters and numbers and add a few characters.
    • API keys, tokens and secrets. Hexadecimal or URL-safe strings work in headers and web addresses without escaping. Python’s documentation says that, as of 2015, 32 bytes (256 bits) of randomness were believed to be enough for typical tokens: that’s a 64-character hexadecimal string.
    • Coupon, invite and voucher codes. Use Uppercase letters or My own characters, tick Leave out look-alikes so nobody confuses 0 and O, and keep Every string different on.
    • Test data and IDs. Make up to 1,000 strings at once and download them as a .txt file, one per line.

    Is this random string generator secure?

    Each character is picked with crypto.getRandomValues, the browser’s cryptographically strong random number generator, not Math.random, which MDN describes as a non-cryptographic source. Characters are picked with rejection sampling, so every character in the set is exactly as likely as every other one.

    The strings are made on your device. They aren’t sent to a server or saved, and a new set replaces the old one when you press Generate strings or change an option. Once you copy a password, treat it like any other secret: don’t paste it into chats or documents other people can see.

    Generate a random string in JavaScript or Python

    To make random strings in your own code, use the cryptographic random source, not the general-purpose one:

    • JavaScript (browser or Node.js): fill an array with crypto.getRandomValues(new Uint32Array(length)) and map each number to a character, drawing again when a number falls in the uneven top of the range.
    • Python: secrets.token_hex(16) returns 32 hexadecimal characters, secrets.token_urlsafe(16) a URL-safe string, and ''.join(secrets.choice(chars) for _ in range(n)) picks from your own characters. Python’s documentation says to use secrets rather than random for anything secret.

    Random string generator FAQ

    How long should a random string be?

    For a password, 16 or more characters from letters, numbers and symbols (103 bits). For an API key or token, 32 to 64 hexadecimal characters (128 to 256 bits). Short codes people type, like invite codes, can be 6 to 10 characters if every code is checked by your system.

    What is a random alphanumeric string?

    A string of letters and numbers only: A–Z, a–z and 0–9, 62 characters in all. Choose Letters and numbers, the default, for a random alphanumeric string generator.

    How do I make a random hex string?

    Choose Hexadecimal (0–9, a–f) or (0–9, A–F) under Characters and set the length. That makes it a random hex string generator; 32 characters give 128 bits.

    Can I leave out similar-looking characters?

    Yes. Tick Leave out look-alikes to drop 0, O, o, 1, l, I and |.

    Are the strings unique?

    With Every string different on, no string in a list repeats. If your settings allow fewer different strings than you asked for, like 2-digit numbers (100), the tool makes all of them and tells you.

    Can I use my own characters?

    Yes. Choose My own characters and type them. Each character you type counts once, however often you type it, and spaces are ignored.

    How many strings can I generate?

    Up to 1,000 strings of up to 1,024 characters each, 1,024,000 characters in one press. The first 300 are shown; Copy all and Download include every one.

    Can I use it as a random code generator for coupons?

    Yes. Use uppercase letters or your own characters, leave out look-alikes and keep Every string different on. Make sure your system checks each code, since anyone could guess a short one eventually.

    Is anything sent or saved?

    No. The strings are made in your browser and nothing is sent or stored.