Skip to content

Limit

The Limit node trims an array to keep only a set number of items, from the start or from the end. It is useful for keeping the first results of a search, taking the last records of a history log, or narrowing a dataset before processing it.

It is equivalent to n8n’s Limit node.

If no source is provided, the node operates on the array received in the previous node’s data. When data is not an array but contains an items or data property that is one, the node uses it automatically.

ParameterTypeRequiredDescription
sourcetextNoDot-notation path to the array within data. Empty = uses data directly. Example: items, result.rows
maxItemsnumberYesNumber of items to keep
keepselectNofirst (default): keeps the first items. last: keeps the last ones

The node returns the trimmed array directly (compatible with other nodes that expect an array):

[
{ "id": 1, "name": "Ana" },
{ "id": 2, "name": "Luis" },
{ "id": 3, "name": "Marta" }
]

If the input is not an array (and has no items/data array), the node returns an error asking you to set source or connect a node that returns an array.

{
"label": "Top 10",
"maxItems": "10",
"keep": "first"
}

Returns the first 10 items of the input array.

{
"label": "Last 5",
"maxItems": "5",
"keep": "last"
}

Keeps only the final 5 items of the array.

{
"label": "First 3 rows",
"source": "result.rows",
"maxItems": "3",
"keep": "first"
}

Takes the array located at result.rows and returns its first 3 rows.

  • The source field supports dynamic and cross-node variables: {{@NodeName.field}}, {{#N.field}}
  • If maxItems is greater than the number of items, it returns the whole array without error
  • Does not require credentials