Random String & Nano ID Generator · Tutorial
How to generate licence keys and coupon codes
5 min readbeginnerUpdated
Codes that people type in by hand, such as licence keys, gift cards and coupons, must be easy to read and hard to guess. You will generate a batch of grouped uppercase codes without confusing characters and check their strength.
What you need
- The Random String Generator
- A spreadsheet or database to store the codes you issue
Steps
Pick uppercase letters and numbers
Set Characters to Uppercase and numbers. Uppercase is easier to read on screens, receipts and gift cards, and people type it the same way every time.
Leave out look-alikes
Tick Leave out look-alikes. The letters O and I and the digits 0 and 1 are removed, so nobody has to guess whether a character was a zero or the letter O.
Set length and grouping
Choose length 16 and Split with dashes every 4 characters. The result looks like
7KQM-X4TD-R9PW-3HNC, which is easy to read aloud and to compare.Check the strength
With 32 characters and length 16 you get 80 bits of randomness. The summary shows you can issue billions of codes before a duplicate becomes likely, and guessing a valid one is hopeless.
Generate and store the batch
Set How many to the number you need, press Generate new and download the list. Import it into your system and mark each code as used when it is redeemed.
Try it yourself
Opens the Random String & Nano ID Generator with this tutorial's sample loaded.
Common mistakes
- Making codes too short
- A six-character code from 32 characters has about a billion values. That sounds a lot, but with thousands of valid codes and no rate limit, guessing one becomes realistic. Use 12 or more.
- Checking codes with the dashes included
- Customers will type codes with or without dashes and in lowercase. Remove dashes and uppercase the input before comparing.
- Relying on the code alone
- Limit how many attempts one person can make and log failed tries, so nobody can test codes at speed.
Next steps
Go back to the Random String & Nano ID Generator, or keep going with one of these:
FAQ
Can I add a product prefix?
Yes. Type it in Prefix, for example PRO-. The prefix adds no randomness, so keep the random part at the same length.