A discount code generator makes a list of unique, random codes so each customer can get their own. Set the number of codes, a prefix, the random length and the characters above; the tool creates the codes in your browser, shows how hard they are to guess, and exports them as .txt or .csv. The Shopify admin’s Create discount page takes one code at a time, so adding a long list to Shopify takes the Admin API or an app.
How do you use this discount code generator?
- Enter the number of codes, from 1 to 10,000.
- Add a prefix such as
SPRING-so the campaign is easy to recognize. Use letters, digits, hyphens and underscores only: Shopify advises avoiding special characters because the code is added to the checkout URL. - Choose how many random characters to use and which characters. Look-alikes (0, O, 1, I and L) are left out by default so codes are easier to type.
- Paste or load the codes already in your store, so none of them is generated again.
- Check the guess chance, then copy or download the codes.
Should you use unique codes or one shared code?
| One shared code | Unique codes | |
|---|---|---|
| Example | WELCOME10 for everyone | SPRING-7KQ4-M2XD, one per customer |
| Setup in Shopify | Type it on the Create discount page | Add a list with the Admin API or an app |
| Sharing | Anyone who sees it can use it | Each code can be limited to one use |
| Suits | Announcement bars, social posts, flyers | Emails to a list, loyalty rewards, service gestures |
A shared code is easier to promote, but if you show it in an announcement bar, assume it will travel. Unique codes suit offers meant for specific people.
How do you set up the discount in Shopify?
Shopify’s steps for an amount off products discount:
- Go to Discounts, click Create discount and choose a type such as Amount off products.
- Under Method, select Discount code, then enter a code or click Generate code.
- Set the value, what it applies to, any minimum requirements and eligibility.
- Under Maximum discount uses, check Limit number of times this discount can be used in total or Limit to one per customer.
- Choose combinations, set active dates and click Save.
Shopify’s legacy price rule reference describes the usage limit as counting per discount code. Before sending a batch, place two test orders with one code to confirm how your limit behaves.
How do you get hundreds of codes into Shopify?
- Admin API: after creating the discount, call
discountRedeemCodeBulkAddwith up to 250 codes per call. It runs asynchronously, and the bulk creation object reportsimportedCountandfailedCount. The app needs thewrite_discountsaccess scope, and new custom apps are created in the Dev Dashboard. Download JSON for the API (under Add with the Admin API) splits your codes into 250-code batches. - Apps: some Shopify App Store apps generate or import code lists. To use the codes made here, check that the app imports your own list.
Shopify sets a cumulative limit of 20,000,000 unique discount codes per store; at the limit you delete codes to create new ones, and apps can’t raise it (Shopify Help Center).
What rules do Shopify discount codes follow?
The legacy DiscountCode reference sets three rules:
- Length: up to 255 characters.
- Uniqueness: a code already in use is rejected with “must be unique. Please try a different code.”
- Case: codes are case-insensitive, as the Storefront API also states, so
spring-7kq4-m2xdandSPRING-7KQ4-M2XDare the same code.
How do you send unique codes to customers?
Use an email or SMS tool that can merge one code from a list into each message, and keep the CSV as a record of who got which code. Don’t post unique codes publicly. Shopify’s Sales by discount report shows how often codes are used.
If you enter your store domain, the CSV gets a link per code in the /discount/code format Shopify uses for shareable links. Shopify doesn’t offer those links in the admin for codes a third-party app created, so open one before sending.
How hard are these codes to guess?
Possible codes = characters ^ random positions. The default, 31 characters in 8 positions, allows 852,891,037,441 codes; with 100 valid codes, a random guess works about once in 8.53 billion tries. Each extra character multiplies the possibilities by 31. Codes are drawn with your browser’s crypto.getRandomValues(), with rejection sampling so no code is favored. A random code can still be forwarded, so pair it with a usage limit and an end date.
What are the limitations?
- The tool doesn’t connect to your store. It only avoids the codes you paste.
- It doesn’t create the discount or set its value.
- Codes aren’t saved. Download them before you reload or leave the page.
To see what a discount does to your margin, use the profit margin calculator.
Frequently asked questions
Does a longer prefix make codes harder to guess?
No. The prefix and suffix are the same on every code, so anyone who has seen one code knows them. Only the random characters add possible codes, which is why the tool counts them alone.
Why leave out 0, O, 1, I and L?
They’re easy to confuse when someone reads a code from an email or a printed card and types it. Leaving them out cuts the character set from 36 to 31, so 8 random characters give 852,891,037,441 possible codes instead of 2,821,109,907,456. That’s still plenty for 10,000 codes. Turn the option off if customers only ever paste or click your codes.
How many discount codes can a customer use on one order?
Up to 5 product or order discount codes and 1 shipping discount code, and only when each discount is set to combine with the others. Codes past the limit don’t apply (Shopify Help Center).
What happens to “one per customer” if I recreate a discount?
The limit belongs to the discount. Shopify says that if you delete a discount limited to one use per customer and add a duplicate with the same restriction, customers who used the original can use the new one once (Shopify Help Center).
Are the generated codes stored anywhere?
No. They’re made on your device and aren’t sent to ShopOpsy. Changing a setting, clicking Generate new codes or reloading the page draws a new list, so download the exact list you plan to send.
Sources
- Shopify Help Center: Discount codes
- Shopify Help Center: Amount off products discounts
- Shopify Help Center: Managing and editing your discounts
- Shopify Help Center: Discount combinations
- Shopify Help Center: Custom apps
- Shopify GraphQL Admin API: discountRedeemCodeBulkAdd
- Shopify GraphQL Admin API: DiscountRedeemCodeBulkCreation
- Shopify REST Admin API (legacy): DiscountCode
- Shopify REST Admin API (legacy): PriceRule
- Shopify Storefront API: Cart (case-insensitive discount codes)
- MDN: Crypto.getRandomValues()
Last updated October 26, 2026