Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Random String & Code Generator

Unique coupon, voucher and invite codes, PINs and test IDs — up to 100,000 at a time.

Developer No upload Works offline Free, no sign-up

Code format

Presets
  • A uppercase letter A–Z
  • a lowercase letter a–z
  • 9 digit 0–9 (also #)
  • X uppercase letter or digit
  • x lowercase letter or digit
  • H hex digit 0–9 A–F
  • h hex digit 0–9 a–f
  • * any character from your character set
  • \ next character is literal
Characters — used by the * placeholder

    A check character is added after the random part and lets a system catch typing mistakes. It is not a security feature.

    Generated codes

    Check a code

    Uses the check character method selected above; the suffix is ignored.

    Next steps

    About the Random String & Code Generator

    Generate batches of random codes for discount coupons, gift vouchers, invite links, PINs, licence keys or test data. Describe the format with a pattern such as XXXX-XXXX or AAA-9999-xx, or pick a character set and a length; add a fixed prefix or suffix and, if you like, a check character so typing mistakes can be caught when a code is entered.

    Every character is chosen with your browser's cryptographically secure random number generator (crypto.getRandomValues), with rejection sampling so that every allowed character is exactly equally likely. With No duplicates on, the batch never contains the same code twice — and the tool tells you up front when fewer distinct codes exist than you asked for. Codes are made on your device and are never sent anywhere.

    How to use it

    1. Pick a preset (coupon codes, vouchers with a check character, PINs, invite codes, licence keys or hex IDs), or set your own format.
    2. Choose Pattern and type a mask such as XXXX-XXXX, or choose Character set and set the length. The legend shows what each placeholder means.
    3. Adjust the characters: tick upper case, lower case, digits or symbols, add your own characters, and avoid look-alike characters or vowels if people will type the codes.
    4. Optionally add a prefix (for example SALE-), a suffix and a check character, then set How many and press Generate.
    5. Copy the list or download it as a .txt or .csv file for your shop, mailing tool or database.

    Examples

    Coupon codes without look-alikes or vowels
    Input
    Pattern XXXX-XXXX · no 0 O 1 I l · no vowels
    Result
    K7QD-82MX
    T3NW-9BZH
    R6PF-4CYL

    Each X is one of 29 characters (A–Z and 0–9 without O, I, 0, 1 and the vowels A, E, U), so there are 29⁸ ≈ 500 billion possible codes. (Examples of the format — generate your own.)

    Vouchers with a check character
    Input
    Pattern XXXX-XXXX-XXX · no 0 O 1 I l · check: Luhn mod N
    Result
    4T8Z-E6SZ-XS9D

    The last character is calculated from the others with Luhn mod 32 over the 32 characters the code uses (2–9 and A–Z without I and O, in that order), so it is never a look-alike either. A till or web form can recompute it and reject a code with a typo before looking it up.

    Escaping a placeholder letter
    Input
    Pattern \A\X-99999
    Result
    AX-48297

    A backslash makes the next character literal, so \A is the letter A rather than a random capital. Characters that are not placeholders, such as -, are always literal.

    Common uses

    • Single-use discount or promo codes for an online shop, a campaign or a newsletter.
    • Gift card and voucher numbers with a check character that catches mistyped codes.
    • Invite and referral codes, event tickets and raffle numbers.
    • PINs, activation codes and licence keys.
    • Unique test IDs and fixture data for databases and QA.

    Pattern placeholders

    • A — an upper-case letter A–Z
    • a — a lower-case letter a–z
    • 9 or # — a digit 0–9
    • X — an upper-case letter or a digit
    • x — a lower-case letter or a digit
    • H / h — a hexadecimal digit (0–9 A–F / 0–9 a–f)
    • * — any character from your character set (the checkboxes and custom characters)
    • \ — makes the next character literal, e.g. \A

    Every other character — -, _, /, spaces, other letters — is copied as it is. The look-alike and vowel exclusions apply to every placeholder.

    How many possible codes do you need?

    The tool shows how many different codes your format allows and the odds that one random guess hits a code in your batch. For coupons that grant money off, keep those odds very small: 10,000 codes in a space of 500 billion means a random guess succeeds about 1 time in 50 million. Shorter formats are easier to type but easier to guess, so also limit how many attempts your checkout allows.

    For secrets that are never typed by people — API tokens, password-reset links — use at least 128 bits (shown under the results), for example 32 hexadecimal characters.

    Check characters

    A check character is calculated from the rest of the code, so a system can detect most typing mistakes without a database lookup. It adds no security: anyone can compute it.

    • Luhn mod N (Luhn mod N algorithm) works over the characters your codes are made of, so the check character is always one of them — with look-alikes excluded it is never a 0, O, 1 or I. The page shows N and the characters in their order (by code point), which is all your own system needs to compute the same check. The algorithm only catches every single-character mistake when N is even, so an odd number of characters is refused.
    • Luhn mod 36 works on letters and digits (letters are read as upper case, other characters such as - are skipped) and detects every single-character mistake. Its check character can be any of A–Z and 0–9, even ones you excluded from the code.
    • Damm and Verhoeff work on digit codes and detect every single-digit mistake and every swap of two neighbouring digits.

    The check character is appended after the random part and before the suffix, and covers the prefix too (Luhn mod N skips prefix characters that are not in its set). Use Check a code to test a code — handy when writing the validation in your own system. Luhn mod 10, the payment-card check digit, is deliberately not offered (not even as Luhn mod N over the ten digits), so that these codes can never look like card numbers.

    Limitations

    • “No duplicates” applies within one batch. Codes from an earlier batch are not remembered, so check new codes against the ones already in your system before importing them (with large code spaces, a clash is extremely unlikely).
    • Up to 100,000 codes per batch and 256 characters per code.
    • Codes that start with =, +, - or @ may be read as formulas when a CSV file is opened in a spreadsheet; the tool warns you when that happens.
    • Nothing is saved: copy or download the codes before leaving the page.

    Privacy

    Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.

    Frequently asked questions

    Are the codes really random?

    Yes. They come from crypto.getRandomValues, the browser's cryptographically secure random number generator, and each character is picked with rejection sampling so every allowed character is equally likely. They are not derived from the time or a counter, so knowing one code does not help to predict another.

    How do I make sure no two codes are the same?

    Keep No duplicates switched on (the default). The generator draws new codes until the batch contains the number you asked for, all different. If your format allows fewer distinct codes than you requested — for example 11 codes from a one-digit pattern — it tells you instead of repeating codes.

    Which characters should I leave out for printed codes?

    Tick Avoid look-alike characters to drop 0, O, o, 1, I, l and |, which are easy to confuse on paper and on screens. Tick No vowels as well to stop codes from accidentally spelling words.

    Can I generate codes in a specific format like ABC-1234?

    Yes — use the pattern AAA-9999: each A becomes a random capital letter and each 9 a random digit, while the hyphen is kept. To keep a fixed word, put it in the prefix (for example SALE-) or escape the letters with a backslash.

    Is a check character enough to stop fake codes?

    No. It only catches accidental mistakes such as a mistyped or swapped character, because anyone can compute it. Real protection comes from a large code space, single-use codes that your system verifies against its database, and a limit on attempts.

    Quick answers and tool search

    Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.