The metafield object

Metafields make it possible to store additional information for articles, blogs, collections, customers, orders, pages, products, the shop, and variants. You can access the metafield object through the metafields attribute of these resources.

Metafields support multiple data types, which determine the kind of information that's stored in the metafield object. You can also apply Liquid metafield filters to this object in order to output metafield information in a standard format.

The metafield object has the following attributes:


Returns the metafield type.


Returns the metafield value.

The following outlines the value format for each metafield type:

Type Returned format
  • single_line_text_field
  • multi_line_text_field
A string
product_reference A product object
variant_reference A variant object
page_reference A page object
file_reference A generic_file object
  • number_integer
  • number_decimal
A number
  • date
  • date_time
A date object
url_reference A url string
boolean A boolean
color A color object
  • weight
  • volume
  • dimension
A measurement object

Access metafields

The access path for metafields consists of two layers:

  • namespace - A grouping of metafields to prevent conflicts.
  • key - The metafield name.

Given this, you can access the metafield object with the following syntax:

For example, you might have the following metafield added to a product:

Type Namespace Key Data
single_line_text_field instructions wash "Cold"

Using this metafield information, the following input generates the following output: