Skip to main content

List of data types

Each metafield has a data type that determines what information it can store. All types have built-in validation and Liquid support. Use this page to explore available types and their expected value formats.

Note

Metaobjects use the same data types.


When you create a metafield definition, the type applies to every instance of that resource. For example, if you create a definition called "Ingredients" with type multi_line_text_field for products, then every product will enforce that type for its "Ingredients" metafield.

Example response

{
"data": {
"product": {
"metafield": {
"namespace": "custom",
"key": "ingredients",
"value": "oat milk,\nsugar,\nchia seeds",
"type": "multi_line_text_field",
"definition": {
"name": "Ingredients",
"ownerType": "PRODUCT"
}
}
}
}
}

When using the Admin API to read and write metafields, the value is always entered and stored as a string, regardless of type.

For information about limits for each metafield type, refer to metafield limits.


Anchor to Metafield type migrationMetafield type migration

You can change the type of a metafield, with some important considerations:

  • Metafields cannot be migrated to type id.
  • When migrating a metafield between incompatible types (for example, from date_time to money), the existing values become invalid. To fix this, use the Shopify admin to clear the invalid value, or use the API to clear the value or change the invalid definition to a compatible one.

Basic types store simple values like text, numbers, and dates. See code samples.

TypeDescriptionValue typeTranslatableMarket localizable
booleanA true or false value.booleannono
colorThe hexadecimal code for a color.stringnono
dateA date in ISO 8601 format without a presumed timezone.stringnono
date_timeA date and time in ISO 8601 format without a presumed timezone. Defaults to Greenwich Mean Time (GMT).stringnono
dimensionA value and a unit of length. Valid unit values: in, ft, yd, mm, cm, mJSON objectnono
idA unique single-line text field. You can add validations for min, max, and regex.stringnono
jsonA JSON-serializable value. This can be an object, an array, a string, a number, a boolean, or a null value.JSON datayesno
linkA text and URL pairing that can be used to store link content.JSON datayesno
moneyA numeric amount, with a currency code that matches the store's currency. You can localize money metafields to a market, but you can't translate them to a different language or locale.JSON objectnoyes
multi_line_text_fieldA multi-line text field.stringyesno
number_decimalA number with decimal places in the range of +/-9999999999999.999999999.stringnono
number_integerA whole number in the range of +/-9,007,199,254,740,991.integernono
ratingA rating measured on a specified scale. Validations are required for ratings and support min and max.JSON objectnono
rich_text_fieldA rich text field supporting headings, lists, links, bold, and italics. Learn more about rich text formatting.JSON objectyesno
single_line_text_fieldA single-line text field.stringyesno
urlA URL with one of the allowed schemes: https, http, mailto, sms, tel.stringyesno
volumeA value and a unit of volume. Valid unit values: ml, cl, l, m3 (cubic meters), us_fl_oz, us_pt, us_qt, us_gal, imp_fl_oz, imp_pt, imp_qt, imp_gal.JSON objectnono
weightA value and a unit of weight. Valid unit values: oz, lb, g, kgJSON objectnono

Anchor to Basic type code samplesBasic type code samples

The following examples demonstrate the expected value format for each basic type:

TypeSample
boolean
true
color
#fff123
date
2022-02-02
date_time
2024-01-01T12:30:00
dimension
{
"value": 25.0,
"unit": "cm"
}
id
1234
json
{
"ingredient": "flour",
"amount": 0.3
}
link
{
"text": "Learn more",
"url": "https://shopify.com"
}
money
{
"amount": "5.99",
"currency_code": "CAD"
}
multi_line_text_field
Ingredients
Flour
Water
Milk
Eggs
number_decimal
10.4
number_integer
10
rating
{
"value": "3.5",
"scale_min": "1.0",
"scale_max": "5.0"
}
rich_text_field
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Bold text.",
"bold": true
}
]
}
]
}
single_line_text_field
VIP shipping method
url
https://www.shopify.com
volume
{
"value": 20.0,
"unit": "ml"
}
weight
{
"value": 2.5,
"unit": "kg"
}

Reference metafields store references to Shopify resources. See code samples.

TypeDescriptionValue typeTranslatableMarket localizable
article_referenceA reference to a blog post.stringnoyes
collection_referenceA reference to a collection.stringnoyes
company_referenceA reference to a company.stringnono
customer_referenceA reference to a customer.stringnono
file_referenceA reference to a file. The default value is GenericFile. You can use validations to add other file types (for example, Image).stringyesno
metaobject_referenceA reference to a metaobject entry. You can use validations to set which metaobject definition the metaobject must be.stringnoyes
mixed_referenceA reference to one of many metaobject definitions. Unlike metaobject_reference which only allows for a single metaobject definition to be set, mixed references allow for metaobjects that belong to different definitions.stringnono
page_referenceA reference to a page.stringnoyes
product_referenceA reference to a product.stringnoyes
product_taxonomy_value_referenceA reference to a product taxonomy value. You can add validations to limit which taxonomy values can be selected. Refer to Shopify Standard Product Taxonomy for available values.stringnono
variant_referenceA reference to a product variant.stringnoyes

Anchor to Reference type code samplesReference type code samples

The following examples demonstrate the expected value format for each reference type:

TypeSample
article_reference
gid://shopify/Article/1
collection_reference
gid://shopify/Collection/1
company_reference
gid://shopify/Company/1
customer_reference
gid://shopify/Customer/1
file_reference
gid://shopify/MediaImage/123
metaobject_reference
gid://shopify/Metaobject/123
mixed_reference
gid://shopify/Metaobject/123
page_reference
gid://shopify/Page/1
product_reference
gid://shopify/Product/1
product_taxonomy_value_reference
gid://shopify/TaxonomyValue/1
variant_reference
gid://shopify/ProductVariant/1

List metafields store multiple values in a single metafield as a JSON array. See code samples.

You can implement list metafields on the online store using sections and blocks. The type of list determines the implementation. For example, you could add a list of product references as a dynamic source to a custom block, or you could add a list of single line text fields to a text or rich text section.

Info

If you delete a product or variant from a store, then the product or variant is automatically removed from all list metafields that reference it.

TypeDescriptionTranslatableMarket localizable
list.article_referenceA list of references to blog posts.nono
list.collection_referenceA list of collection references.nono
list.colorA list of hexadecimal color codes.nono
list.customer_referenceA list of references to customers.nono
list.dateA list of dates in ISO 8601 format without presumed timezones.nono
list.date_timeA list of dates and times in ISO 8601 format without presumed timezones. Defaults to Greenwich Mean Time (GMT).nono
list.dimensionA list of values and a unit of length. Valid unit values: in, ft, yd, mm, cm, m.nono
list.file_referenceA list of references to files. The default value is GenericFile. You can use validations to add other file types (for example, Image).yesno
list.idA list of unique single-line text fields. You can add validations for min, max, and regex.nono
list.linkA list of text and URL pairings that can be used to store a collection of links.yesno
list.metaobject_referenceA list reference to one or more metaobject entries that belong to a single metaobject definition. Unlike list.mixed_reference, all metaobject entries referenced must be of the same definition.nono
list.mixed_referenceA list reference to one or more metaobject entries that may belong to different metaobject definitions.nono
list.number_decimalA list of numbers with decimal places in the range of +/-9999999999999.999999999.nono
list.number_integerA list of whole numbers in the range of +/-9,007,199,254,740,991.nono
list.page_referenceA list of references to pages.nono
list.product_referenceA list of product references.nono
list.product_taxonomy_value_referenceA list of references to product taxonomy values. You can add validations to limit which taxonomy values can be selected. Refer to Shopify Standard Product Taxonomy for available values.nono
list.ratingA list of ratings measured on a specified scale. Validations are required for ratings and support min and max.nono
list.single_line_text_fieldA list of single-line text fields.yesno
list.urlA list of URLs with one of the allowed schemes: https, http, mailto, sms, tel.yesno
list.variant_referenceA list of references to product variants.nono
list.volumeA list of values and a unit of volume. Valid unit values: ml, cl, l, m3 (cubic meters), us_fl_oz, us_pt, us_qt, us_gal, imp_fl_oz, imp_pt, imp_qt, imp_gal.nono
list.weightA list of values and a unit of weight. Valid unit values: oz, lb, g, kgnono

Anchor to List type code samplesList type code samples

The following examples demonstrate the expected value format for each list type:

TypeSample
list.article_reference
[
"gid://shopify/Article/1",
"gid://shopify/Article/2"
]
list.collection_reference
[
"gid://shopify/Collection/1",
"gid://shopify/Collection/2"
]
list.color
[
"#FFF123",
"#E6E6FA",
"#00FF00"
]
list.customer_reference
[
"gid://shopify/Customer/1",
"gid://shopify/Customer/2"
]
list.date
[
"2022-01-01",
"2022-05-05"
]
list.date_time
[
"2024-01-01T12:30:00",
"2024-05-01T12:30:00"
]
list.dimension
[
{"value": 25.0, "unit": "cm"},
{"value": 35.0, "unit": "cm"}
]
list.file_reference
[
"gid://shopify/MediaImage/123",
"gid://shopify/MediaImage/456"
]
list.id
[
"1234",
"5678"
]
list.link
[
{"text": "Start a business", "url": "https://shopify.com"},
{"text": "Read the docs", "url": "https://shopify.dev/docs"}
]
list.metaobject_reference
[
"gid://shopify/Metaobject/123",
"gid://shopify/Metaobject/456"
]
list.mixed_reference
[
"gid://shopify/Metaobject/123",
"gid://shopify/Metaobject/456"
]
list.number_decimal
[
"10.4",
"20.5",
"30.6"
]
list.number_integer
[
"10",
"20",
"30"
]
list.page_reference
[
"gid://shopify/Page/1",
"gid://shopify/Page/2"
]
list.product_reference
[
"gid://shopify/Product/1",
"gid://shopify/Product/2"
]
list.product_taxonomy_value_reference
[
"gid://shopify/TaxonomyValue/1",
"gid://shopify/TaxonomyValue/2"
]
list.rating
[
{"value": "3.5", "scale_min": "1.0", "scale_max": "5.0"},
{"value": "4.5", "scale_min": "1.0", "scale_max": "5.0"}
]
list.single_line_text_field
[
"VIP shipping method",
"Standard shipping method"
]
list.url
[
"https://www.shopify.com",
"https://www.shopify.dev"
]
list.variant_reference
[
"gid://shopify/ProductVariant/1",
"gid://shopify/ProductVariant/2"
]
list.volume
[
{"value": 20.0, "unit": "ml"},
{"value": 40.0, "unit": "ml"}
]
list.weight
[
{"value": 2.5, "unit": "kg"},
{"value": 4.5, "unit": "kg"}
]

Anchor to Rich text formatting detailsRich text formatting details

The rich_text_field metafield type accepts a JSON object that uses the following general structure:

{
"type": "root",
// The root holds an array of paragraphs and lists. Each paragraph represents a section of text that's separated by a line break.
"children": [
{
"type": "paragraph",
// A paragraph holds an array of formatted text objects and URL objects, where the objects are concatenated to form the text within the paragraph.
"children": [
// Formatted text object
{
"type": "text",
"value": "This is italicized text and ",
"italic": true
},
// URL object
{
"url": "https://example.com",
"title": "Link to example.com",
"type": "link",
"children": [
// Formatted text object that's embedded in the URL object.
{
"type": "text",
"value": "a bolded hyperlink",
"bold": true
}
]
}
]
}
]
}
The rich text editor, showing the words

Refer to the following code samples for examples of the objects that can be used to represent fragments of rich text:

{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "This text is bolded and italicized.",
// To bold or italicize the text, set the "bold" or "italic" values to true. The default value is false.
"bold": true,
"italic": true
}
]
}
]
}
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "heading",
"children": [{
"type": "text",
"value": "This is an H1 heading"
}],
// The heading level
"level": 1
}
]
}
]
}
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"url": "https://example.com",
// The URL title is used for accessibility and SEO purposes.
"title": "Link to example.com",
"type": "link",
// The following array of formatted text represents the text that's visible to the user.
"children": [{
"type": "text",
"value": "This is a hyperlink"
}]
}
]
}
]
}
{
"type": "root",
"children": [
{
// The listType accepts "ordered" or "unordered".
"listType": "ordered",
"type": "list",
"children": [
{
"type": "list-item",
// Each list item holds an array of formatted text.
"children": [{
"type": "text",
"value": "This is the first list item."
}]
},
{
"type": "list-item",
"children": [{
"type": "text",
"value": "This is the second list item."
}]
}
]

}
]
}


Was this page helpful?