Export recipe

Export Shopify discount codes and their usage to a CSV

Already have the file?

Drop it into the converter. It reads it in your browser and gives you a CSV.

Runs in your browser. Your file is never uploaded.

Convert my file

What the admin can’t do

Discounts > Export gives a broad overview of your discounts (Help Center, Exporting discounts). It is export only; codes can’t be imported by CSV.

A bulk query asks Shopify to collect everything in the background and hand you one file to download. It reads data only; it can’t change your store. Shopify keeps the download link for 7 days.

Run it with Shopify CLI (recommended)

You need Shopify CLI installed on your computer. shopify store auth asks you to approve access in your browser, then shopify store bulk execute runs the export.

  1. Save the query below in a file named discounts.graphql.
  2. Run the two commands. The first opens your browser to approve access (scopes: read_discounts). The second waits for the export and saves it as discounts.jsonl.
discounts.graphql
{
  discountNodes(query: "method:code") {
    edges {
      node {
        id
        discount {
          __typename
          ... on DiscountCodeBasic {
            title
            status
            startsAt
            endsAt
            asyncUsageCount
            usageLimit
            appliesOncePerCustomer
            summary
            codesCount {
              count
            }
          }
          ... on DiscountCodeBxgy {
            title
            status
            startsAt
            endsAt
            asyncUsageCount
            usageLimit
            appliesOncePerCustomer
            summary
            codesCount {
              count
            }
          }
          ... on DiscountCodeFreeShipping {
            title
            status
            startsAt
            endsAt
            asyncUsageCount
            usageLimit
            appliesOncePerCustomer
            summary
            codesCount {
              count
            }
          }
          ... on DiscountCodeApp {
            title
            status
            startsAt
            endsAt
            asyncUsageCount
            usageLimit
            appliesOncePerCustomer
            codesCount {
              count
            }
          }
        }
      }
    }
  }
}
Terminal
shopify store auth --store your-store.myshopify.com --scopes read_discounts
shopify store bulk execute --store your-store.myshopify.com --version 2026-10 \
  --query-file discounts.graphql --watch --output-file discounts.jsonl

Or with Shopify’s GraphiQL app

  1. Install Shopify’s GraphiQL app on your store and tick these scopes: read_discounts. Choose API version 2026-10.
  2. Paste the mutation below and run it. Copy the id it returns.
  3. Paste the status query, put the id in it, and run it every minute or so until status is COMPLETED.
  4. Open the url it returns to download the .jsonl file.
Start the export
mutation {
  bulkOperationRunQuery(
    query: """
    {
      discountNodes(query: "method:code") {
        edges {
          node {
            id
            discount {
              __typename
              ... on DiscountCodeBasic {
                title
                status
                startsAt
                endsAt
                asyncUsageCount
                usageLimit
                appliesOncePerCustomer
                summary
                codesCount {
                  count
                }
              }
              ... on DiscountCodeBxgy {
                title
                status
                startsAt
                endsAt
                asyncUsageCount
                usageLimit
                appliesOncePerCustomer
                summary
                codesCount {
                  count
                }
              }
              ... on DiscountCodeFreeShipping {
                title
                status
                startsAt
                endsAt
                asyncUsageCount
                usageLimit
                appliesOncePerCustomer
                summary
                codesCount {
                  count
                }
              }
              ... on DiscountCodeApp {
                title
                status
                startsAt
                endsAt
                asyncUsageCount
                usageLimit
                appliesOncePerCustomer
                codesCount {
                  count
                }
              }
            }
          }
        }
      }
    }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
      code
    }
  }
}
Check the status
query {
  bulkOperation(id: "PASTE_THE_ID_HERE") {
    status
    errorCode
    objectCount
    url
    partialDataUrl
  }
}

Turn it into a CSV

  1. Open the JSONL to CSV converter.
  2. Drop in discounts.jsonl. It’s read in your browser; nothing is uploaded.
  3. Choose One row per discount, then click Download CSV.

Columns you get

discount.__typename
DiscountCodeBasic (amount or percentage off), DiscountCodeBxgy (buy X get Y), DiscountCodeFreeShipping or DiscountCodeApp.
discount.asyncUsageCount
Times the discount was used. Shopify updates it in the background, so it can lag slightly.
discount.codesCount.count
How many codes the discount has.
code / asyncUsageCount (codes query)
Each code and how many times that code was used.

Get every code of one discount

Individual codes can’t be pulled in a bulk query (Shopify’s DiscountRedeemCode type doesn’t implement Node, which bulk connections require). Run this normal query in GraphiQL or with shopify store execute for each discount whose codesCount is more than 1. Paste the id from the first export. If hasNextPage is true, run it again with "cursor" set to endCursor.

Query
query DiscountCodes($id: ID!, $cursor: String) {
  discountNode(id: $id) {
    id
    discount {
      __typename
      ... on DiscountCodeBasic {
        title
        codes(first: 250, after: $cursor) {
          pageInfo {
            hasNextPage
            endCursor
          }
          nodes {
            code
            asyncUsageCount
            createdAt
          }
        }
      }
      ... on DiscountCodeBxgy {
        title
        codes(first: 250, after: $cursor) {
          pageInfo {
            hasNextPage
            endCursor
          }
          nodes {
            code
            asyncUsageCount
            createdAt
          }
        }
      }
      ... on DiscountCodeFreeShipping {
        title
        codes(first: 250, after: $cursor) {
          pageInfo {
            hasNextPage
            endCursor
          }
          nodes {
            code
            asyncUsageCount
            createdAt
          }
        }
      }
      ... on DiscountCodeApp {
        title
        codes(first: 250, after: $cursor) {
          pageInfo {
            hasNextPage
            endCursor
          }
          nodes {
            code
            asyncUsageCount
            createdAt
          }
        }
      }
    }
  }
}
Variables
{ "id": "gid://shopify/DiscountCodeNode/123", "cursor": null }

Scopes: read_discounts. This is a normal query, not a bulk one. In GraphiQL, paste the query and variables and run it. With the CLI: shopify store execute --store your-store.myshopify.com --query-file query.graphql --variable-file variables.json --output-file result.json. Paste or drop the result into the converter.

Limits

  • The bulk query filters to code discounts with method:code, a documented discountNodes filter. Automatic discounts are left out.
  • Paste each page of the codes query into the converter (you can paste several responses back to back) and choose "one row per codes".
  • Every type and field in these queries was checked against Shopify’s GraphQL Admin API reference for version 2026-10. We haven’t run them on a live store. If Shopify returns an error, the message names the field or scope it’s missing.
  • Bulk queries allow up to five connections, two levels deep (Shopify bulk operation limits).

More recipes

Sources: discountNodes query, discountNode query, DiscountCodeBasic, DiscountRedeemCode, Exporting discounts (Help Center). Not affiliated with, endorsed by, or sponsored by Shopify Inc. Shopify is a trademark of Shopify Inc.