Sanity Schema: Should I Store All Product Variants in Array vs Default Fields?

18 replies
Last updated: Nov 29, 2025
Battling with the notion of product “variants”! Is there any reason it would be unhelpful to craft your schema as:

Title
Artists (reference to maker[s])
Variants Label (e.g. "Size")
Variants (array, if only one type of product, only one variant)
    Title
    Price
    Quantity
    SKU
    Tax Level
    Weight
Body
Details
Categories
Essentially – omit the “Default” variant fields you see in Shopify-type schema, and simply store ALL variants in an array? If there’s no variants, there would only be one item in “Variants” and no “Variant Label”

Its frustrating when you have a store where variations will be relevant for less than 2% of products…
AI Update

Your proposed schema approach is actually quite sensible and aligns well with how Sanity handles flexible content structures! There's no technical reason this wouldn't work, and it can be a much cleaner solution for your use case.

Why your approach works well:

  1. Simplicity for simple products - Products without variants just have a single item in the variants array. No need to maintain redundant "default" fields at the product level plus variant-specific fields.

  2. Consistency - All pricing, inventory, and SKU data lives in the same place regardless of whether there's one variant or multiple. Your queries and UI components can treat everything uniformly.

  3. Flexibility - When a product does need variants, you just add more items to the array and populate the "Variants Label" field. The schema doesn't force complexity on products that don't need it.

Things to consider:

  • Required fields: Make sure your variants array requires at least one item, and consider validation rules to ensure the first (or only) variant has all necessary fields populated.

  • Display logic: In your Studio, you might want to conditionally hide the "Variants Label" field when the array only has one item, or show a simplified UI for single-variant products.

  • Query patterns: Your GROQ queries will need to handle the variants array, but this is straightforward. For example, getting the price range: "priceRange": {"min": min(variants[].price), "max": max(variants[].price)}

  • Frontend logic: Your storefront will always look in the variants array, which is actually simpler than checking "does this product have variants? If yes, look here, if no, look there."

The Shopify-style schema with default fields exists because their data model has constraints that Sanity doesn't. With Sanity's flexible schema system, you can model your content to match your business logic rather than working around platform limitations.

If less than 2% of your products need variants, this approach will make your content editing experience much cleaner for the 98% of cases. Just make sure your Studio UI and validation rules guide editors appropriately for that single-item-array scenario.

Show original thread
18 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?