Metafield types

Each metafield and metafield definition has a type, which defines the type of information that it can store.

For metafield definitions, this type is enforced across every instance of the resource that owns the metafield definition. For example, if you create a metafield definition called "Ingredients" of type multi_line_text_field with an owner type of product, then the metafield's type will be multi_line_text_field for every product.

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

Metafields and definitions can have the following types:

Name API name Description Example value Value type (deprecated) equivalent
Single line text single_line_text_field A single-line text field. This item contains dairy products. string
Multi-line text multi_line_text_field A multi-line text field. Ingredients:
Flour
Water
Milk
Eggs
string
Page reference page_reference A reference to a page on the online store. gid://shopify/OnlineStorePage/1 string
Product reference product_reference A reference to a product on the online store. gid://shopify/Product/1 string
Variant reference variant_reference A reference to a product variant on the online store. gid://shopify/ProductVariant/1 string
File reference file_reference A reference to a file on the online store. gid://shopify/MediaImage/123 string
Integer number_integer A whole number in the range of +/-9,007,199,254,740,991. 10 integer
Decimal number_decimal A number with decimal places in the range of +/-9999999999999.999999999. 10.4 string
Date date A date in ISO 8601 format without a presumed timezone. 2021-02-02 string
Date and time date_time A date and time in ISO 8601 format without a presumed timezone. 2021-01-01T12:30:00 string
URL url A URL with one of the allowed schemes: https, http, mailto, sms, tel. https://www.shopify.com string
JSON string json A JSON-formatted string.
Note: The json_string type is deprecated but does still exist because it behaves differently than the new json type in Liquid.
[{ "k": "v1" }, { "k": "v2" }] json_string
Boolean boolean A true or false value. true boolean
Color color The hexadecimal code for a color. #fff123 string
Weight weight A value and a unit of weight. Valid unit values: oz, lb, g, kg { "unit": "kg", "value": 2.5 } json_string
Volume volume A 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. { "unit": "ml", "value": 20.0 } json_string
Dimension dimension A value and a unit of length. Valid unit values: in, ft, yd, mm, cm, m { "unit": "cm", "value": 25.0 } json_string