How can I extract values from a custom JSON Metafield using Flow?

Topic summary

Issue: A user is attempting to extract values from a custom JSON metafield in Shopify Flow to update order metafields on order creation. The metafield contains nested shipping day data for different countries (default and nl).

Technical Challenge:

  • Flow currently treats all metafields as strings, not parsed JSON objects
  • Direct object property access syntax (e.g., {{ shipping_days["nl"] }}) doesn’t work in Flow
  • Attempts to loop over the metafield or access nested values result in “invalid variable” errors

Current Limitation: The metafield value appears as a string representation of the JSON object rather than an accessible data structure.

Recommendation: A Shopify representative (paul_n) advises finding an alternative approach, as working with JSON metafields in Flow is currently very difficult. The team is exploring improvements for custom data (metafields and metaobjects) accessibility in Flow, but no timeline is provided.

Status: Unresolved - awaiting future Flow enhancements or requiring a workaround outside of Flow’s current capabilities.

Summarized with AI on November 16. AI used: claude-sonnet-4-5-20250929.

I’ve tried to update an order metafield on order created. The information I want to use for the update is stored in a custom json metafield. It contains:

{
    default: {
        shipping_days_min: 3,
        shipping_days_max: 5,
    },
    nl: {
        shipping_days_min: 6,
        shipping_days_max: 12,
    }
}

I get access within the flow to the metafield with this code:

{%- for mf in shop.metafields -%}
{%- if mf.namespace == "countries" and mf.key == "shipping_days" -%}
	{%- assign shipping_days = mf.value -%}
        {{ shipping_days }}
{%- endif -%}
{%- endfor -%}

mf.value / shipping_days contains:

{"default":{"shipping_days_min":3,"shipping_days_max":5},"nl":{"shipping_days_min":1,"shipping_days_max":3}}

I’ve tried to pull out the value for “nl”:

{{ shipping_days["nl"] }}

But then I’ve got an error.
“shop.metafields.value.nl” is invalid. Replace this variable.

I also tried to loop over shipping_days, but it also failed.

Does anyone have any ideas?

Kind regards, Carolin

All metafields are currently treated as strings because that’s how they are passed to Flow through the API. In addition, you cannot access elements in an object (even if it was an object) using that syntax in Flow:

{{ shipping_days["nl"] }}

We are currently looking at ways to make using custom data (metafields and metaobjects) way better and more intuitive in Flow. Ideally here, you wouldn’t need to loop over metafields (very large) and that JSON object would be accessible in Flow in some way like what you are trying to do there.

Until then, you’ll need to assume that value is a string. In this case, it’s going to be really difficult to work with and I’d probably find a different approach until this is ready.

1 Like