Magento 2 Color Swatches Guide: Definition, Configuration & Import

- E-Commerce, Magento 2

Magento 2 Color Swatches

Today, we are going to talk about Magento swatches  – an important element of many configurable product pages. The lack of decent product content is what prevents ecommerce businesses from booming. However, you can always enrich your offer with the help of built-in tools, such as Magento 2 color swatches

Below, we are going to describe what Magento color swatches are. After that, you will learn how to create color swatches in Magento 2. And, of course, there is a section dedicated to the import process. You will learn what attributes are used for Magento 2 swatches. Next, we explain how to compose a CSV with product information that incorporates color swatches. After that, you will master the Magento 2 color swatch import

What Are Magento Swatches?

In Magento 2, swatches are selectable options for a configurable product represented as buttons. Usually, there are two types of swatches in Magento 2:

  • Visual swatches;
  • Text swatches.

What are the color and size swatches then? Well, they are just examples of visual and text swatches correspondingly. Below, you can see how color (visual) and size (text) swatches are represented in a category:

Magento 2 Swatches text and visual

By clicking on different swatches, customers can switch between the corresponding product images that illustrate child products with the selected parameters. It is an intuitive process that leaves your clients with no questions open:

Magento 2 swatches on a product page: size and color selection

Magento 2 provides the ability to use both text and visual swatches on product pages, product listings, and layered navigation. In this tutorial, we, however, focus on Magento color swatches and other visual swatches. 

Visual swatches in Magento 2 are images and color icons that provide information about product variations. Similar to text swatches, they are unique attributes available for configurable products that enable specific customer interactions with such products.

Magento configurable product swatches offer a great way to provide flexible offers in your store. User-friendly and intuitive product variations help appeal to all types of customers and increase sales significantly. That’s why visual swatches with their very illustrative purpose are so important. They enhance configurable product variations with images of color, pattern, material, etc.  

How to Set Up Magento 2 Color Swatches

Now, that you are familiar with Magento swatches, let’s see how to create color swatches in Magento 2.

Step 1: Add New Attribute

New Magento visual (color) swatches can be added to the database under Stores > Attributes > Product as follows:

  1. Click the Add New Attribute button.
    Magento 2 Color Swatches: add new attribute
  2.  Give a swatch attribute title and select ‘Visual Swatch’ from the attribute type dropdown.
    Magento 2 Color Swatches - visual swatches
  3. Set Values required to No.
  4. Set Updated Product Preview Image to Yes if you want your product image to update corresponding to the chosen color swatch.
  5. Set Product Image for Swatch if Possible to No.
    Magento 2 Color Swatches: attribute properties
  6. Leave Advanced Attribute Properties at default.
    Magento 2 Color Swatches: advanced attribute properties

Now, you can proceed to the next step of the Magento 2 color swatch creation – the selection of swatch colors.

Step 2: Manage Swatch – Add Colors

Here, we have Magento 2 color swatches available in multiple colors:

Magento 2 Color Swatches: manage swatches

Push the Add Swatch button to add a new color to the selection. You have two options:

  • Choose a new color from the palette;
  • Upload an image.

Color Selection for Magento 2 Color Swatches

You can select a new color option for your visual swatches in Magento 2 as follows:

  1. Click on the arrow in your swatch;
  2. Choose the “Choose a color” option.
    Magento 2 Color Swatches: choose color
  3. Enter a hexadecimal code or use the color picker and hit the button in the bottom right corner.Magento 2 Color Swatches: color picker
  4.  Set a name for this swatch in the Admin column.
    Magento 2 Color Swatches: add name

Image Upload for Magento Swatches 

Alternatively, you can create visual swatches based on images that represent the necessary pattern, color, or texture for your configurable products. Follow these steps to upload images for Magento 2 color swatches:

  1. Choose “Upload a file instead of “Choose a color.”
    Magento 2 Color Swatches: upload image
  2. Provide a file you want to use as a visual swatch.
  3. Review your Magento 2 color swatch:
    Magento 2 Color Swatch with image
Now, you can add as many new color swatches to Magento 2 as you wish. Remember to Save your attribute before leaving the page.

Step 3: Add Magento 2 Swatches to Products

Now, we’d like to draw your attention to the last step of the Magento 2 configurable swatches configuration. Below, you will learn how to add swatches to a configurable product in Magento 2:

  1. Navigate to Catalog -> Products and select a configurable product to add Magento swatches to.
  2. Scroll down to the Configurations section and click the Edit Configurations button.
    Magento 2 Color Swatches: assign to product
  3. Select attributes associated with Magento 2 swatches and click Next.
    Magento 2 Color Swatches: select attributes
  4. Next, choose swatches to display on a storefront as a part of this configurable product.
    Magento 2 Color Swatches: select attribute values
  5. Now, you can link a unique product image per each color swatch:
    – Choose Apply unique images by attribute to each SKU in Images;
    – Now, select your attribute that represents color swatches in Magento 2;
    – Upload a unique product imager per each color.
    Magento 2 Color Swatches: apply unique image per swatch
  6. View the results in the Summary section.
    Magento 2 Color Swatches: check swatches in a configurable product

Now, let’s find our configurable product in the catalog to test how well the Magento swatches are synchronized with the image display:

Magento 2 Color Swatches: swatches link to images

As you can see, everything works according to the configurations: when you switch between color swatches, the corresponding product images replace one another. Since we didn’t bind unique images to size swatches, switching between them doesn’t impact the image section. But you can change that following the instructions above.

Keep in mind that Magento 2 supports text swatches as well. The text swatches generation is similar to that of visual swatches. You can transfer them following the steps of the visual swatch import we describe below.

Magento 2 Color Swatch Import

Now, let’s talk about the Magento 2 swatch import. The Improved Import and Export extension lets you import swatches to Magento 2 in a couple of ways. Firstly, it is possible to stick to a color code. Secondly, you can specify an image URL which is the most efficient way to retrieve product images from the manufacturer’s side without storing the images at your hardware.

Magento 2 visual swatches can be imported following two different logic patterns:

  • As a single color attribute;
  • Within additional attributes of a configurable product.

Both types allow implementing a color swatch via a particular color code or an image URL. 

Single Color Attribute CSV

In Magento 2, swatch import within the color attribute can be run upon defining these base attributes: sku, attribute_set_code, and color in the import data table. You can find their detailed descriptions in the table below:

Attribute Name Reference Values Value Example
sku A unique value that is used to identify the product. The only mandatory field. SKU is the first field of the table and cannot be removed.

Supports letters, numbers, and signs “-“, “_”. Can be up to 64 characters in length. Can not contain white spaces. 

Mind the letter case!

You can find SKUs for products already in the catalog at Catalog > Products.

attribute_set_code Defines Attribute Set assigned to the product. It should look the same as an attribute set name including capital letters (e.g. “Default”, “Man shoes” etc.)

Attribute set name can be found under Stores > Attribute Set

attibute_set_code – is the default value for this column.

This is also a mapping column containing ALL available product attributes, in case you need a quick reference to map data.

color An attribute that specifies product color. Any color name, color code, or URL. Can include special signs. Values should be divided by a vertical bar “|”.

Visual swatch as a color attribute value contains extra syntax:

type=1 — defines color code import

type=2 — defines import via image URL

Blue Navy|type=2|value=





A CSV for the Magento 2 swatches import as a part of a color attribute looks as follows:

It contains multiple additional columns. For further information, follow this Sample Google Sheets spreadsheet.

CSV with The additional_attributes Column

Let’s explore another way to import color swatches to Magento 2 – the additional_attributes column. Simply add it to the product import table.

The swatch values will have the same syntax as the color attribute’s values during the single swatch attribute import. The base attributes for such import are sku, attribute_set_code, and additional_attributes; they must be specified for a successful swatch data implementation.

As you can see, it is also possible to place more information in the additional_attributes column than in the color column. For instance, there is also the size swatch specified along with the color. See the Sample Google Sheets CSV for more information. Each column has a detailed description there.

How to Import Magento 2 Color Swatches

With a Magento 2 color swatch CSV, you can proceed to the import procedure associated with the Improved Import and Export extension. Follow these steps to import color swatches to Magento 2:

  1. Go to System > Improved Import / Export > Import Jobs and press the “Add New Job” button to create a new job.
    Magento 2 Color Swatches import
  2. In the first section, specify the job name and set the job schedule if you want to import Magento swatches automatically.
    Magento 2 Color Swatches: import as product update
  3. Proceed to the Import Settings section. Select the entity you want to import to your Magento 2 store – Products.
  4.  Then, specify the behavior of the import job: Add/Update, Replace, or Delete. Select the behavior carefully and proceed. If you want to add more swatches to the existing products, specify the Add/Update as the import behavior. In case you want to replace existing swatches or, stick to the Replace behavior.Magento 2 Color Swatches: import behavior
  5. Now, it’s time to choose a file format and source of your file with Magento 2 color swatches. Note that it can be either the standard CSV format or something more specific, such as XML, JSON, ODS, or XLSX.
    When it comes to file sources, the Improved Import & Export provides the ability to import swatches to Magento 2 from Google Sheets, Google Drive, over FTP/SFTP, or even via API.
    Magento 2 Color Swatches import: file format selection
  6. Once you’ve selected the file from the specified source, hit the ‘Validate file’ button. If your file is correct, you can click the ‘Save & Run’ button followed by ‘Run’ to start the import job.
  7. Once the import is finished you will get a log with information about how the import went.
    import Magento 2 Color Swatches

Magento 2 swatch import is extremely useful when you need to save time on creating and applying swatches to products manually. During this process, you can both generate new swatches or assign the existing ones to SKUs of configurable products. There’s no need to add a parent configurable to an import table, as the functionality matches swatches to specified SKUs.

All in all, you can significantly simplify the database update routine with Improved Import and Export while still reaching out to customers with strong visual content and interactive offers. Try out the extension and see how much you can benefit from a single data management solution.

 Get Improved Import and Export

Magento 2 Color Swatches FAQ

Below, we provide answers to questions that Magento 2 users often ask when it comes to the color swatch import.

How to import color swatches to Magento 2 automatically?

If you need to transfer color swatches to Magento 2 regularly, it is necessary to install a third-party tool. Unfortunately, the default import/export solutions don’t let you create import jobs that run on schedule. Therefore, we recommend you use the Improved Import & Export extension to import color swatches to Magento 2 automatically. The extension leverages cron so that you can create a schedule of updates. Next, the module does everything for you.

How to run Magento 2 color swatches import from external systems?

While the default Magento 2 import mechanisms block the import of third-party data that doesn’t follow the system’s requirements, you can use the Improved Import & Export extension to circumvent these restrictions. The module lets you create a mapping scheme matching any external values to the default Magento 2 attributes. Consequently, any external data is easily adapted to the native standards of your e-commerce website. The most intriguing aspect is that you do everything right in your admin.

How to run Magento color swatches import via API?

You need to use the Improved Import & Export Magento 2 extension to import color watches to Magento 2 via API. Our extension lets you create the connection between the two systems transferring any data, including color swatches and product images. Any import job provides an interface where you can specify the parameters necessary to put the two systems together.

How to import color swatches to Magento 2 via ODS files?

If the color swatch data is stored in an ODS file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, it is possible to import ODS files to your ecommerce website without any necessity to run the conversion.

How to run Magento 2 swatches import via XLSX files?

If the color swatch data is stored in an XLSX file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, it is possible to import XLSX files to your ecommerce website without any necessity to run the conversion.

How to import color swatches to Magento 2 via JSON files?

If the color swatch data is stored in an ODS file, you no longer need to convert it to a CSV file to fit the Magento 2 requirements. With the Improved Import & Export Magento 2 extension, it is possible to import JSON files to your ecommerce website without any necessity to run the conversion.

How to run Magento swatches import with compressed files?

If the color swatch data is stored in a compressed file, you can also transfer it to Magento 2 with the help of the Improved Import & Export extension. However, there are two requirements to follow. Firstly, your file archive should be in a ZIP or TAR format. Secondly, the compressed data should be stored in a CSV, XML, ODS, XLSX, or JSON file.

How to import color swatches to Magento 2 from Google Sheets?

If your color swatch data is stored in Google Sheets, it is no longer a problem. There is no need to export it from the service and then transfer the output to Magento 2. The Improved Import & Export lets you move the corresponding information straight from Google Sheets to your e-commerce website. It is only necessary to specify the address of the corresponding data table.

How to import color swatches to Magento 2 from Dropbox?

In addition to Google Sheets, the Improved Import & Export module lets you transfer color swatches to Magento 2 from Dropbox. Your data should be stored in CSV, XML, ODS, XLSX, or JSON. If it is a compressed file, it should be in a ZIP or TAR format.

How to import color swatches to Magento 2 from Google Drive?

In addition to Google Sheets and Dropbox, the Improved Import & Export module lets you transfer color swatches to Magento 2 from Google Drive. Your data should be stored in CSV, XML, ODS, XLSX, or JSON. If it is a compressed file, it should be in a ZIP or TAR format.

Final Words

Magento 2 color swatches are an integral part of Magento 2 in general and configurable products in particular. They dramatically improve the visual representation of complex items, providing customers with a better shopping experience. As a store administrator, you can easily create Magento swatches and assign them to products, connecting each swatch to a particular product image.

On the other hand, the Improved Import & Export extension introduces a more straightforward procedure associated with the Magento 2 color swatch import. In this case, you provide all the necessary information, including image URLs and color codes, and assign it to products. Follow this link to discover more improvements our extension adds to Magento’s standard data management routine:

Improved Import and Export Extension