Data types

Metafields use data types to define the content that can be stored. Each data type has built-in format validation. Regardless of the data type, metafield values are passed and stored as strings. In theme templates, you can access metafields through the metafield object.


Base types​

Base type metafields store text, numbers, dates, and measurements with units.

TypeDescriptionValue type
booleanA boolean value (true or false).boolean
colorA hexadecimal color code.string
dateA date in ISO 8601 format without a time zone.string
date_timeA date and time in ISO 8601 format without a time zone. Greenwich Mean Time (GMT) is used by default.string
dimensionA numeric length value and unit.
Valid units are:
  • mm: Millimeters
  • cm: Centimeters
  • m: Meters
  • in: Inches
  • ft: Feet
  • yd: Yards
JSON object
jsonA JSON-serializable value, which can be an object, array, string, number, boolean value, or null.JSON object
linkA combination of text and a URL for storing link content.JSON object
moneyA monetary amount with a currency code that matches the store currency.JSON object
multi_line_text_fieldA multiline text field with a maximum size of 65 KB.string
number_decimalA decimal number ranging from -9,999,999,999,999.999999999 to 9,999,999,999,999.999999999.string
number_integerAn integer ranging from -9,999,999,999,999 to 9,999,999,999,999.integer
ratingA rating within a specified range. The scale_min and scale_max validation parameters are required.JSON object
rich_text_fieldA rich text field that supports headings, lists, links, bold text, and italic text.JSON object
single_line_text_fieldA single-line text field with a maximum size of 65 KB.string
urlA URL that supports the following protocols: https, http, mailto, sms, and tel.string
volumeA numeric volume value and unit.
Valid units are:
  • ml: Milliliters
  • cl: Centiliters
  • l: Liters
  • m3: Cubic meters
  • us_fl_oz: US fluid ounces
  • us_pt: US pints
  • us_qt: US quarts
  • us_gal: US gallons
  • imp_fl_oz: Imperial fluid ounces
  • imp_pt: Imperial pints
  • imp_qt: Imperial quarts
  • imp_gal: Imperial gallons
JSON object
weightA numeric weight value and unit.
Valid units are:
  • kg: Kilograms
  • g: Grams
  • lb: Pounds
  • oz: Ounces
JSON object

Base type code examples​

The following examples show the expected value format for each base type:

TypeExample
boolean
true
color
#e84c3d
date
2026-04-24
date_time
2026-04-24T12:30:00
dimension
{
"value": 25.5,
"unit": "cm"
}
json
{
"title": "Summer collection",
"stock": 100
}
link
{
"text": "Learn more",
"url": "https://www.shopline.com"
}
money
{
"amount": "5.99",
"currency_code": "CNY"
}
multi_line_text_field
Ingredients
Flour
Water
Milk
number_decimal
9.99
number_integer
42
rating
{
"value": "4.0",
"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
Express shipping
url
https://www.shopline.com
volume
{
"value": 20.5,
"unit": "ml"
}
weight
{
"value": 2.5,
"unit": "kg"
}

Reference types​

Reference type metafields store references to store resources.

TypeDescriptionValue type
collection_referenceA reference to a product collection.string
file_referenceA reference to a file.string
metaobject_referenceA reference to a metaobject entry.string
page_referenceA reference to a page.string
product_referenceA reference to a product.string
variant_referenceA reference to a product variant.string
article_referenceA reference to an article.string

Reference type code examples​

TypeExample
collection_reference
gid://shopline/collections/1
file_reference
gid://shopline/MediaImage/123
metaobject_reference
gid://shopline/Metaobject/2
page_reference
gid://shopline/Page/1
product_reference
gid://shopline/Product/1
variant_reference
gid://shopline/ProductVariant/1
article_reference
gid://shopline/Article/1

List types​

List type metafields store multiple values in a single metafield. Values are represented as JSON arrays. Each list type metafield can contain up to 128 elements.

TypeDescription
list.colorA list of hexadecimal color codes.
list.collection_referenceA list of product collection references.
list.dateA list of dates in ISO 8601 format.
list.date_timeA list of dates and times in ISO 8601 format.
list.dimensionA list of numeric length values and units.
Valid units are:
  • mm: Millimeters
  • cm: Centimeters
  • m: Meters
  • in: Inches
  • ft: Feet
  • yd: Yards
list.file_referenceA list of file references.
list.linkA list of text and URL combinations for storing multiple links.
list.metaobject_referenceA list of metaobject entry references.
list.number_decimalA list of decimal numbers.
list.number_integerA list of integers.
list.page_referenceA list of page references.
list.article_referenceA list of article references.
list.product_referenceA list of product references.
list.ratingA list of ratings within a specified range.
list.single_line_text_fieldA list of single-line text fields.
list.urlA list of URLs that support the https, http, mailto, sms, and tel protocols.
list.variant_referenceA list of product variant references.
list.volumeA list of numeric volume values and units.
Valid units are:
  • ml: Milliliters
  • cl: Centiliters
  • l: Liters
  • m3: Cubic meters
  • us_fl_oz: US fluid ounces
  • us_pt: US pints
  • us_qt: US quarts
  • us_gal: US gallons
  • imp_fl_oz: Imperial fluid ounces
  • imp_pt: Imperial pints
  • imp_qt: Imperial quarts
  • imp_gal: Imperial gallons
list.weightA list of numeric weight values and units.
Valid units are:
  • kg: Kilograms
  • g: Grams
  • lb: Pounds
  • oz: Ounces

List type code examples​

TypeExample
list.color
["#e84c3d", "#3498db", "#2ecc71"]
list.collection_reference
["gid://shopline/collections/1", "gid://shopline/collections/2"]
list.date
["2026-01-01", "2026-05-01"]
list.date_time
["2026-01-01T12:30:00", "2026-05-01T12:30:00"]
list.dimension
[
{
"value": 25.5,
"unit": "cm"
},
{
"value": 35.5,
"unit": "cm"
}
]
list.file_reference
["gid://shopline/MediaImage/123", "gid://shopline/GenericFile/456", "gid://shopline/video/789"]
list.link
[
{
"text": "Get started",
"url": "https://shopline.com"
},
{
"text": "View documentation",
"url": "https://developer.shopline.com/docs"
}
]
list.metaobject_reference
["gid://shopline/Metaobject/123", "gid://shopline/Metaobject/456"]
list.number_decimal
["9.99", "19.9", "99.0"]
list.number_integer
["1", "5", "42"]
list.page_reference
["gid://shopline/Page/1", "gid://shopline/Page/2"]
list.article_reference
["gid://shopline/Article/1", "gid://shopline/Article/2"]
list.product_reference
["gid://shopline/Product/1", "gid://shopline/Product/2"]
list.rating
[
{
"value": "4.0",
"scale_min": "1.0",
"scale_max": "5.0"
},
{
"value": "2.5",
"scale_min": "1.0",
"scale_max": "5.0"
}
]
list.single_line_text_field
["Express shipping", "Standard shipping"]
list.url
["https://www.shopline.com", "https://developer.shopline.com"]
list.variant_reference
["gid://shopline/ProductVariant/1", "gid://shopline/ProductVariant/2"]
list.volume
[
{
"value": 20.5,
"unit": "ml"
},
{
"value": 40.5,
"unit": "ml"
}
]
list.weight
[
{
"value": 2.5,
"unit": "kg"
},
{
"value": 4.5,
"unit": "kg"
}
]

Rich text format​

The rich_text_field type accepts JSON objects with the following structure:

{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "This is regular text.",
"bold": true,
"italic": true
},
{
"type": "link",
"url": "https://example.com",
"title": "Example link",
"children": [
{
"type": "text",
"value": "Learn more",
"bold": true
}
]
}
]
}
]
}

Bold and italic​

Text nodes use bold and italic to set text styles. The fields are described as follows:

FieldRequiredDescription
typeYesFixed as text.
valueYesThe content of the text node.
boldNoWhether the text is bold. The default value is false.
italicNoWhether the text is italic. The default value is false.

Example​

{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "This text is bold and italic.",
"bold": true,
"italic": true
}
]
}
]
}

Headings​

The fields of a heading node are described as follows:

FieldRequiredDescription
typeYesFixed as heading.
levelYesThe heading level. Supported values range from 1 to 6.
childrenYesAn array of text nodes.

Example​

{
"type": "root",
"children": [
{
"type": "heading",
"level": 2,
"children": [
{
"type": "text",
"value": "This is a level 2 heading"
}
]
}
]
}

The fields of a link node are described as follows:

FieldRequiredDescription
typeYesFixed as link.
urlYesThe destination URL of the link.
titleNoThe link title, which can be used for accessibility and search engine optimization (SEO).
targetNoThe target for opening the link. For example, _blank opens the link in a new tab.
childrenYesAn array of text nodes.

Example​

{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"url": "https://example.com",
"title": "Link to example.com",
"target": "_blank",
"children": [
{
"type": "text",
"value": "View details"
}
]
}
]
}
]
}

Lists​

The fields of list nodes and list item nodes are described as follows.

List node:

FieldRequiredDescription
typeYesFixed as list.
listTypeYesThe list type. Supported values are ordered and unordered.
childrenYesAn array of nodes with type set to list-item.

List item node:

FieldRequiredDescription
typeYesFixed as list-item.
childrenYesAn array of text nodes.

Example​

{
"type": "root",
"children": [
{
"type": "list",
"listType": "unordered",
"children": [
{
"type": "list-item",
"children": [
{
"type": "text",
"value": "First item"
}
]
},
{
"type": "list-item",
"children": [
{
"type": "text",
"value": "Second item"
}
]
}
]
}
]
}
Was this article helpful to you?