How to check for empty node output

Hi, I’m trying to use an IF node to detect empty output from a node, but I’m unable to get anything but true from it - how can I test for empty values coming out of a node?

First of all you have to know that n8n does not advance the chain if no data is available.
To avoid this, there is this setting in the respective node:
grafik
Than you can use a function to check if items are empty with:

items.length == 1 && Object.keys(items[0].json).length == 0

Here a complete example:

5 Likes

Can we have the complete example please?

my bad, it was ublock that hid the workflows :slight_smile:

Thank you! I elaborated another method based on your code to very simply put this directly inside a switch as an expression, so that one can then use the boolean result to determine which way to go:

{{Object.keys($items()[0].json).length === 0}}

6 Likes