Shopify Flow Run Code Generator

Describe what a workflow step should work out and get the Input query, Output schema and JavaScript for Flow's Run code action.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your brief

These form details are sent to our AI provider when you generate. Review the result before publishing.

Run code has three separate fields

  • Input: a GraphQL query against the workflow's own data (what the trigger and earlier steps produced), whose result becomes your function's input argument.
  • Output: a GraphQL SDL type Output { ... } definition. Your function must return a plain object matching it exactly, and downstream steps read it from a variable named Run code.
  • JavaScript: export default function main(input) { ... }, doing the actual logic.

What it can't do

LimitValue
LanguageECMA2020 JavaScript only, no Node.js/CommonJS APIs, no import
NetworkNo fetch or any HTTP call
RandomnessNo Math.random, no clock-based functions like Date.now()
SizeInput query and Output schema: 5,000 characters each. Code: 50,000 characters. Output + console.log: 50KB combined
Runtime5 seconds, 10MB memory

These are real constraints, not stylistic ones: code that calls fetch or imports a module won't run. If your idea needs an API call, it needs a proper Flow app action or a webhook, not Run code.

Adding it to a workflow

  1. 01

    Add the action

    In Shopify Flow, build your trigger and conditions, then add the Run code action.

  2. 02

    Paste the three fields

    Input into the Input box, Output schema into Output, and the JavaScript into the code editor.

  3. 03

    Test it

    Use Flow's test run against a real record and check the Run code variable's returned values before turning the workflow on.

Questions people ask

Is the Input query the same as the Admin API?

No. It queries Flow's own workflow data (what the trigger and earlier steps expose), not the Shopify Admin GraphQL API directly.

Can Run code call an external API?

No, fetch and other HTTP calls aren't available inside it. For that you need an app-based Flow action or a webhook.

Why does my code fail with an import error?

Run code doesn't support import, require or any Node.js/CommonJS API. Everything the function needs has to be plain JavaScript in the same file.

What debugging output can I see?

Only console.log, shown in the workflow's run log, not console.error or console.info.

I need to query the Admin API directly instead.

Use the Shopify GraphQL query generator for that.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com

Last reviewed 30 September 2026.

Sources: Shopify Help: Run code action reference