Use built-in shortcuts
n8n provides built-in methods and variables for working with data and accessing n8n data. This section provides a reference of available methods and variables for use in expressions, with a short description.
Availability in the expressions editor and the Code node
Not every method and variable in this reference works in the Code node. The Code node runs plain JavaScript against native Luxon, not n8n's expression engine, so any entry marked Source: Custom n8n functionality on a reference page (for example, DateTime.format()) is an n8n-only extension that may not exist, or may behave differently, in the Code node.
If code in the Code node throws ... is not a function, or silently produces the wrong result:
Check whether the method's reference entry is tagged Custom n8n functionality.
Look for a native Luxon or JavaScript equivalent. For example, use
toFormat()instead of the n8n-onlyDateTime.format().Watch for methods that exist in both places but with different signatures, such as
DateTime.plus()/minus(): n8n's expression version accepts(amount, unit), while native Luxon's version only accepts a single Duration-like object ({ days: 7 }). Using the expression-style signature in the Code node won't error, but won't produce the expected result either.
All data transformation functions (the top-level helper functions listed in this section, such as $if() or $jmespath()) are only available in the expressions editor, not the Code node.
The Cookbook contains examples for some common tasks, including some Code node only functions.
Last updated
Was this helpful?