Coupon code generator — unique promo codes in bulk, with guess odds

Choose a prefix, how many segments and how long each one is, and the tool makes up to 5,000 unique promo codes, shows how hard a code is to guess, and gives you a CSV ready for your shop's import.

Live demo · real result from this tool

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the coupon code generator

  1. Type a Prefix, such as SAVE or BF26, or leave it empty.
  2. Set the number of Segments (1 to 6) and the Characters per segment (2 to 10).
  3. Choose a Separator of up to three characters (a dash by default; leave empty for none).
  4. Pick the Characters: A–Z and 2–9 without look-alikes, A–Z and 0–9, Letters only or Digits only.
  5. Set How many codes (up to 5,000) and press Generate. Copy the list or download the CSV.

What it does and when to use it

Single-use coupon codes power welcome discounts, referral rewards, influencer campaigns, event tickets and gift vouchers. Each code must be unique, easy to type and hard to guess, because people do try guessing codes from a known pattern. This tool handles all three, and the CSV saves you from copying thousands of codes by hand.

The prefix is not secret. It tells customers and your team which campaign a code belongs to. The random segments carry the security. For codes that count up rather than being random, use the order number generator. For a free-form pattern that mixes letters and digits in fixed places, see the serial number generator. For staff or account passwords, use the bulk password generator.

How it works

Each segment is filled with characters picked by crypto.getRandomValues, with every character in the set equally likely. The prefix and segments are joined with the separator, and repeats are discarded.

  • Random part = segments × characters per segment × log2(set size). Only the random characters count, not the prefix.
  • Chance one random guess is a valid code = number of possible codes ÷ number of codes issued. A guesser who knows the format still needs that many tries, on average, for each hit.

Worked examples

  • The defaults. Prefix SAVE, 2 segments of 4 from the 32-character set give codes like SAVE-EB2J-YD3Z with Random part: 40 bits. For a batch of 3, a guess has a 1 in 366,503,875,925 chance.
  • One plain block. No prefix, 1 segment of 8: codes like 3CGQTEJN, and for 2 codes Chance one random guess is a valid code: 1 in 549,755,813,888.
  • Too small a format. 1 segment of 2 digits holds only 100 codes, so a request for 200 stops with “Only 100 distinct values fit this pattern — ask for fewer or make it longer.”

Limits and tips

  • Rate-limit coupon entry on your checkout. Good codes help, but limits stop automated guessing.
  • Store codes in your shop, not in public spreadsheets.
  • Letters-only codes can spell words by accident. Glance through the list before you send it out.

Frequently asked questions

Will any two codes in a batch be the same?
No. The tool throws away repeats and keeps drawing until it has the number you asked for. If the format cannot hold that many codes, it says so instead. It cannot see codes from earlier batches, so let your shop system reject duplicates when you import.
How long should coupon codes be?
Long enough that guessing is hopeless. Look at the "1 in …" figure, which already takes the size of your batch into account. Eight characters from the default set give about 1 in 55 billion for a batch of 20. Short codes like SAVE-23 can be guessed in minutes, so keep those for public, unlimited offers only.
Why are 0, O, 1 and I missing?
The default set "A–Z and 2–9 without look-alikes" drops characters people confuse when they read a code off a flyer or type it on a phone. That set has 32 characters, so each one carries exactly 5 bits.
How do I load the codes into my shop?
Download coupon-codes.csv. It has one column with the header "code" and one code per line, which most e-commerce platforms and spreadsheets can import. Set the discount, limits and expiry in the shop itself.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close