Batch-generate unique discount codes for your Shopify store. Connect via the Admin API, select products, and generate hundreds of codes in one go.
- Connect to any Shopify store using a legacy custom app access token
- Select multiple products to apply discounts to
- Generate 1–4000 unique discount codes at once
- Set discount amount, usage limit per code, and expiration date
- Customizable code prefix (e.g.
SUMMER25_) - Preview generated codes, view summary stats, and download as CSV
node server.jsOpen http://localhost:3001 in your browser.
No npm install needed — the server uses Node.js built-in http module with zero external dependencies.
This version uses the legacy custom app flow and expects a manually copied Admin API access token:
- In Shopify Admin, go to Settings -> Apps and sales channels
- Allow Legacy Custom App development (if needed and available on the store)
- Create a legacy custom app named
Discounts Generator - Under API Credentials, configure Admin API scopes:
read_productsread_discountswrite_discountsread_price_ruleswrite_price_rules
- Click Save, then Install the app
- Reveal the Admin API access token once and copy it into this tool
Enter the store's full Shopify URL and Admin API access token, then click Connect Store. The tool verifies the token and fetches products.
Search and select one or more products, set the discount amount, quantity of codes to generate, usage limit per code, an optional expiration date, and a code prefix.
The prefix is prepended to each generated code — for example US_10_RESERVATION_ produces codes like US_10_RESERVATION_A3K9X2M1.
Click Generate Codes. The tool creates a Shopify Price Rule tied to the selected products, then generates all discount codes via the batch API (with a fallback to individual creation). After completion, the results are displayed with a preview of the first 5 codes.
You can:
- Download CSV — exports all generated codes with Code, Title, Discount, Usage Limit, and Expires columns
- Create More — returns to the configuration step to generate another batch
ShopifyBulkDiscountCreator/
├── server.js # HTTP server with Shopify Admin API integration
├── public/index.html # Single-page frontend (vanilla HTML/CSS/JS)
└── package.json # Start script
Validates an existing Admin API access token and fetches products and variants.
Request:
{ "shop": "your-store.myshopify.com", "accessToken": "shpat_..." }Response:
{
"success": true,
"products": [
{ "id": 456, "title": "Product Name", "variantCount": 1, "priceLabel": "29.99" }
],
"variants": [
{ "id": 123, "productId": 456, "title": "Default Title", "price": "29.99", "displayName": "Product Name - Default Title" }
],
"shop": "your-store.myshopify.com",
"accessToken": "shpat_..."
}Creates a price rule and generates discount codes.
Request:
{
"shop": "your-store.myshopify.com",
"accessToken": "shpat_...",
"amount": "10",
"quantity": "50",
"usageLimit": "1",
"endsAt": "2027-01-01",
"codePrefix": "SALE_",
"productIds": ["456", "789"]
}Response:
{
"success": true,
"discounts": [
{ "code": "SALE_A3K9X2M1", "title": "$10 off", "amount": "10", "usageLimit": 1, "endsAt": "2027-01-01T00:00:00.000Z" }
]
}- Node.js 18+ (uses native
fetch) - A Shopify store with a legacy custom app access token that has the Admin API scopes listed above
- The Price Rules REST API is used for discount creation. While this API is legacy, it remains the most common and reliable approach for bulk discount code generation.
- Product restrictions use Shopify product IDs and apply to all variants of each selected product.
- Batch generation uses the async batch endpoint with polling. If the batch fails, the tool falls back to creating codes individually.
- Rate limiting is handled by Shopify's built-in throttling; the tool does not add additional queuing.
- Code characters use uppercase letters and digits (36-character alphabet) with 8 random characters per code.