Find a variant ID

Variant IDs are sometimes needed to make theme code customizations that target specific product variants. If you need to find a variant ID, you can do so from within your Shopify admin.

  1. From your Shopify admin, click Products.

  2. Click on a product.

  3. Once you are viewing a product, look at your browser's URL bar. You should see a URL similar to this:

    At the end of the URL, add .xml.

    Using the example URL above, the result looks like this:
  4. Press the Enter key, so that your browser redirects to a new page.

    You will see an XML file that contains all of the variant information for that product. The information for all of the variants is found within an opening <variants type="array"> tag, and a closing </variants> tag. Inside the <variants> element, the information for each unique variant is nested in its own <variant> element. You'll see that each <variant> element contains other elements, such as <id>, <title>, <price>, and so on.

  5. Look for the for the <title> tag inside a <variant> element. In this case, the title is a summary of the product options that make up the variant, with the options separated by /s. For example, if you want to find the ID for a variant with options for Color, Fabric, and Size, and the values for these options are Blue, Cotton, and Small, then the XML code will look like this:

    <title>Blue / Cotton / Small</title>
  6. Once you find the <title> for the variant, look for an <id> tag within the same <variant> element. The <id> tag is two lines above the <title> tag, and looks similar to this:

    <id type="integer">657848769</id>

    The number found within the <id> element is the variant ID. In the above example, the variant ID is 657848769.

Sample xml

Want to discuss this page?

Visit the Shopify Community