Counter

Simple counter that increments each time data passes through

Counter

AI-generated

Overview

This node implements a simple counter that increments each time data passes through it during workflow execution. It is useful for scenarios where you want to keep track of how many times a particular part of your workflow has been executed or how many items have passed through the node. For example, you might use it to count processed records, track iterations in loops, or generate sequential identifiers within a workflow.

Properties

Name Meaning
Counter Name The name identifier for this counter. Allows multiple counters to be tracked separately by name. Default is "default".
Reset Counter Boolean option to reset the specified counter back to zero before incrementing. Useful to restart counting at any point.

Output

The node outputs the incoming data unchanged but adds a new field count to the JSON part of each item. This count field contains the current value of the named counter after incrementing. Binary data, if present on input items, is passed through unchanged.

Output structure per item:

{
  "json": {
    "...original fields...",
    "count": <current counter value>
  },
  "binary": {
    "...original binary data if any..."
  }
}

Dependencies

No external services or API keys are required. The node uses internal static workflow data storage to maintain counter values across executions.

Troubleshooting

  • If the counter does not increment as expected, ensure that the "Counter Name" property is consistent and correctly set.
  • Using the "Reset Counter" option will reset the counter to zero; if unexpected resets occur, verify this property is not unintentionally enabled.
  • Since the counter state is stored statically within the workflow execution context, restarting the workflow or clearing static data will reset all counters.

Links and References

  • n8n Documentation: Static Data Storage
  • General usage of counters in workflows can be found in various automation pattern guides.

Discussion