Offering discount codes is a proven technique to convert more visitors into customers. In Magento 2, you can create coupon codes in a few easy steps and get your campaigns running.
In this guide, you’ll learn how to create coupon code in Magento 2 and examples.
How to Create a Coupon Code in Magento 2?
Magento 2 has a concept of “Cart price rules” that define the rules (conditions) for discounts. In the cart price rule, you can create a specific coupon code required to avail the discount. You can also auto-generate coupon codes in Magento 2 for the cart price rule.
Method 1: Create a Specific Coupon Code
To create a Magento 2 discount code, navigate to Marketing > Promotions > Cart Price Rules in your admin.

In the Cart Price Rules grid, click the “Add New Rule” button.

Enter a name and description for the cart price rule and select the applicable websites and customer groups.
To specify a coupon code for the discount, set Coupon to “Specific Coupon” and define your coupon code.

Optionally, you can also specify certain conditions and rules for the discount from the Conditions section.
You can set limits on the number of uses per coupon code or customer. And also define a specific date range for the validity of the coupon code.
It’s helpful to set a Magento 2 coupon expiration date for time-sensitive discounts.

Next, expand the Actions section to define the discount. In this example, we’re setting a 75% discount on the cart. You can also set a fixed amount or buy X get Y discount.

Click the “Save” button to save the cart price rule with discount code.
That’s how straightforward it is to create a specific discount code in Magento 2.
Method 2: Auto-generate Coupon Codes in Bulk
In Magento 2 cart price rules, you can use the auto-generation feature to create coupon codes in bulk.
To do that, check the “Use Auto Generation” option against the Coupon Code field.

Now, configure the Conditions and Actions for the discount rule as per your needs and click “Save and Continue Edit” on the top right to save the rule. (This is important since you will not be able to generate the coupon codes without saving the rule)

Scroll down to the Manage Coupon Codes section and configure the coupon code settings. Enter the quantity and length of the coupon codes you want to generate and select the format.
Click the “Generate” button.

Once generated, you can find the list of coupon codes in a grid under the same section.

That’s how you can have Magento 2 auto-generated coupon codes. You can start distributing these discount codes to your customers and promote the sales.
You can test the created Magento 2 coupon code on the shopping cart page in the front end.

Ta-da! You’ve successfully created and applied a discount code in your Magento 2 store.
Examples of Magento 2 Coupon Codes
Magento 2 discount codes are helpful for promoting sales, and they’re more effective when used strategically. Here are some popular examples of how to create and use Magento 2 discount codes more effectively.
Product-specific Coupon Code
In Magento 2 cart price rules, you can set up conditions to offer discounts only on certain products. This can be useful while running seasonal sales.
Let’s say you want to create a discount code for a specific product in your Magento 2 store. You can do this by matching its SKU in the conditions section. Create a new cart price rule with the coupon code for the discount offer and add the conditions to match the product by its SKU, as shown below.

You can define multiple rules and logic in the conditions section to create Magento 2 discount codes using product attributes like SKU, category, brand, etc.
Customer Group-specific Coupon Code
You can change the scope of the cart price rules to create discount codes for specific customers in Magento 2. To do that, you’ll need a customer group to which you want to offer the discount.
Simply follow the above steps to create a discount code in Magento 2 using the cart price rules and select the customer group to which you want to offer it.

This way, you can create exclusive discount codes for your loyal customers in Magento 2.
Convert coupon codes to link that apply discount directly at checkout.
Get ExtensionBonus: How to Promote Magento 2 Discount Codes Using Links?
Take the customer experience of your store to the next level (literally) with coupon code links. Our Magento 2 Coupon Code Link extension converts your normal coupon codes into links that customers can use to grab deals.
Using the extension, you can:
- Convert existing coupon codes into links
- Redirect links to specific pages in your store
- Auto-apply discount code on the cart page
Make it easier for the customers to grab deals and discounts in your store. Create links for discount codes and share anywhere.