Discount code importer
Make or upload a list of unique codes, then add them to a Shopify discount without an app. Shopify has no CSV import for codes, so this writes the exact API calls for you to run.
1Your codes
First codes
2Which discount gets the codes
Paste the discount’s ID (gid://shopify/DiscountCodeNode/…) or its number. Not sure? Run the lookup query below. Codes are added to this discount and share its value, dates and limits.
Not sure of the ID? Look it up
Run this query in GraphiQL. It lists your 25 newest code discounts with their IDs.
query FindCodeDiscounts {
codeDiscountNodes(first: 25, reverse: true) {
nodes {
id
codeDiscount {
__typename
... on DiscountCodeBasic { title status }
... on DiscountCodeBxgy { title status }
... on DiscountCodeFreeShipping { title status }
... on DiscountCodeApp { title status }
}
}
}
}3Add the codes to Shopify
Add codes (step 1) and a discount ID (step 2) to get your batches.
- Install Shopify’s free GraphiQL app on your store and tick the
read_discountsandwrite_discountsscopes. - Paste the mutation below into the query box once.
- Copy batch 1 into the Variables box and press Run. Repeat for each batch.
- Copy every response into step 4 to see which codes failed.
mutation AddDiscountCodes($discountId: ID!, $codes: [DiscountRedeemCodeInput!]!) {
discountRedeemCodeBulkAdd(discountId: $discountId, codes: $codes) {
bulkCreation {
id
}
userErrors {
code
field
message
}
}
}- Install Shopify CLI, then sign in to your store once:
shopify store auth --store your-store.myshopify.com --scopes read_discounts,write_discounts - Download the script and run
bash add-discount-codes.shin the same folder. - Paste the file it writes,
discount-code-results.jsonl, into step 4.
4Check the results
Shopify adds codes in the background. Paste the responses from step 3 here. We read the job IDs, then give you a query to check each job. Paste those answers here too and we list any code that failed.
query CheckDiscountCodeJob($id: ID!) {
discountRedeemCodeBulkCreation(id: $id) {
id
done
codesCount
importedCount
failedCount
codes(first: 250) {
nodes {
code
errors {
field
message
}
}
}
}
}| Code | Why it failed |
|---|
How it works
- Shopify has no code import
- The admin can export discount codes but not import them. Shopify’s API can, through
discountRedeemCodeBulkAdd, up to 250 codes per call. - Nothing to install from us
- You run the calls with Shopify’s own free GraphiQL app or Shopify CLI. We never see your store or your codes.
- Clean lists
- Duplicates that differ only in capitals are removed (Shopify codes aren’t case sensitive), and codes over 255 characters or with spaces are flagged.
- Know what failed
- Paste Shopify’s answers back in to get a list of codes that weren’t added and why, ready to fix and retry.
Guides
Questions
Can Shopify import discount codes from a CSV?
Not from the admin. Shopify can export discount codes but has no import button. Shopify’s own API can add up to 250 codes per call to an existing discount, which is what this tool sets up for you.
Do I need to install an app?
You need a way to run Shopify’s API on your store. The free route is Shopify’s GraphiQL app (made by Shopify) or Shopify CLI. Both are free. No paid or third-party app is involved.
Are my codes uploaded anywhere?
No. Codes are generated and batched in your browser. They only reach Shopify when you run the mutations yourself.
Are Shopify discount codes case sensitive?
No. SAVE10 and save10 are the same code, so this tool removes duplicates that differ only in capitals. Codes can be up to 255 characters, and Shopify suggests avoiding special characters.
Is there a limit on how many codes I can have?
Shopify allows 20,000,000 unique discount codes per store in total. This tool makes or batches up to 100,000 at a time.
Based on Shopify’s discountRedeemCodeBulkAdd and discountCodeBasicCreate reference (API 2026-10). Not affiliated with, endorsed by, or sponsored by Shopify Inc. Shopify is a trademark of Shopify Inc.