Code settingsExample

1 to 10,000.

Added in front of every code, in the case chosen under Letter case. Include a hyphen if you want one.

Every code looks like SPRING-####-#### (# is one random character)

Code format8 random · A–Z 0–9
Format

1 to 32, not counting the prefix, suffix or hyphens.

Added after every code, in the same case. Letters, digits, hyphens and underscores.

Hyphens
Characters
Letter case

Shopify treats discount codes as case-insensitive, so this only changes how they look.

Codes to skip
Codes to skip (optional)

Paste codes already in your store, one per line or separated by commas. Shopify codes must be unique and ignore case, so these are matched without regard to case and never generated again.

Shareable links
Shareable links (optional)

Adds a Link column to the CSV in the /discount/code format Shopify uses for shareable discount links. Open one link to check it applies the discount before you send them.

Your discount codes100 codesHard to guess

Your discount codes

100 unique codes, 16 characters each, hard to guess.

100 unique codes

Hard to guess

16 characters each. A random guess has a 1 in 8.53 billion chance of matching one.

Creating your codes in this browser…

How hard to guess1 in 8.53 billion
Possible codes853 billion31 characters in 8 positions
Chance a guess works1 in 8.53 billionPer attempt, for any of your codes
Code length16 charactersShopify allows up to 255

Hard to guess. Someone typing random codes in this format would need about 8.53 billion tries, on average, to hit one that works.

How the numbers are worked out

  • Possible codes = characterspositions = 31⁸ = 852,891,037,441
  • Chance a guess works = valid codes ÷ possible codes = 100 ÷ 852,891,037,441 = 1 in 8.53 billion

ShopOpsy’s rule of thumb: 1 in a billion or rarer is hard to guess; more often than 1 in a million is too easy. Codes are drawn with your browser’s crypto.getRandomValues(), with rejection sampling so every possible new code is equally likely.

Add with the Admin API
Admin API calls1Up to 250 codes per call

Create the discount in Shopify first, then send these codes to it with the discountRedeemCodeBulkAdd mutation, up to 250 per call. It runs asynchronously: query discountRedeemCodeBulkCreation with the returned ID to see how many codes were imported or failed. The app making the call needs the write_discounts access scope.

mutation discountRedeemCodeBulkAdd($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {
  discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {
    bulkCreation {
      id
    }
    userErrors {
      code
      field
      message
    }
  }
}

The download below holds one set of variables per call (1 call for these codes). Replace the placeholder discountId with your discount’s DiscountCodeNode ID.

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?

  1. Enter the number of codes, from 1 to 10,000.
  2. 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.
  3. 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.
  4. Paste or load the codes already in your store, so none of them is generated again.
  5. Check the guess chance, then copy or download the codes.

Should you use unique codes or one shared code?

One shared codeUnique codes
ExampleWELCOME10 for everyoneSPRING-7KQ4-M2XD, one per customer
Setup in ShopifyType it on the Create discount pageAdd a list with the Admin API or an app
SharingAnyone who sees it can use itEach code can be limited to one use
SuitsAnnouncement bars, social posts, flyersEmails 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:

  1. Go to Discounts, click Create discount and choose a type such as Amount off products.
  2. Under Method, select Discount code, then enter a code or click Generate code.
  3. Set the value, what it applies to, any minimum requirements and eligibility.
  4. Under Maximum discount uses, check Limit number of times this discount can be used in total or Limit to one per customer.
  5. 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 discountRedeemCodeBulkAdd with up to 250 codes per call. It runs asynchronously, and the bulk creation object reports importedCount and failedCount. The app needs the write_discounts access 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-m2xd and SPRING-7KQ4-M2XD are 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

Last updated October 26, 2026

More free Shopify tools

All tools

ROAS Calculator

Marketing

Work out ROAS, break-even ROAS and target ROAS from your margin, plus max cost per acquisition and per click.

Shopify Barcode Generator

Products & catalog

Make UPC, EAN and Code 128 barcodes with correct check digits, and print label sheets from a list or a Shopify product CSV.

Shopify Profit Margin Calculator

Pricing & profit

Work out profit, net margin and markup per order after fees, shipping, ads and refunds, or the price you need for a target margin.