Learn how to use static data in n8n to store values, persist workflow information, and simplify automation setup.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
To use static data in n8n, you store it on the workflow level using the built‑in $input.item.json-like object called $workflow.staticData. n8n keeps this data between workflow executions, so you can read and write to it without a database. It’s meant for small, simple state like counters, timestamps, or configuration values you don’t want hard‑coded in nodes.
Static data is a special JSON object attached to a workflow. Unlike normal node data, which only exists during a single run, static data is persisted by n8n and is available on the next execution. Think of it as tiny permanent storage built into the workflow.
You access it in expressions or in Function / Function Item nodes through $workflow.staticData. If the workflow uses triggers (Cron, Webhook, etc.), static data will survive between runs as long as your n8n instance can persist executions (most setups do).
You typically interact with it inside a Function or Function Item node. Here’s a clean example that increments a counter:
// Access staticData in "global" mode (persists across executions)
const data = $workflow.staticData;
// Initialize if missing
if (!data.counter) {
data.counter = 0;
}
// Update it
data.counter++;
// Return current counter
return [{ counter: data.counter }];
This counter will survive every time your workflow runs. No database needed.
Static data comes in two flavors:
Both persist across executions. Global is what most production workflows use.
You can also read static data directly in UI expressions without a Function node. For example:
// Example expression
{{$workflow.staticData.lastRunTimestamp}}
This is helpful if you store configuration values and want to reference them anywhere.
Static data only saves when the workflow successfully finishes. If the workflow errors, the changes to static data are not written. This is intentional so you don’t corrupt your “saved state” mid‑execution.
This behavior affects things like counters or pagination trackers, so plan accordingly.
This is common when pulling from an API that doesn’t support webhooks.
const data = $workflow.staticData;
// read last ID or set default
const lastId = data.lastId || 0;
// call your API here (this is an example)
const newId = lastId + 5; // pretend we got new data
// store the updated ID
data.lastId = newId;
// output something
return [{ lastProcessed: newId }];
This makes sure the next time the workflow runs, it knows where it left off.
In short: using static data in n8n is the simplest way to give your workflow memory. It’s small, reliable, and perfect for lightweight state that needs to persist across executions.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.