Docs
Sign in

Code

The Code node runs your own code as a step in a workflow, in Python, JavaScript or TypeScript.

Screenshot to add: A Code node showing its language tag, and its settings panel with the Language, Code, Dependencies and Output key fields.

The palette describes it as "Run custom code".

When to use it

Use it when no other node does what you need and you are comfortable writing a small piece of code. For a simpler form that focuses on one language, see Python or JavaScript.

Settings

FieldWhat it doesNotes
LanguageThe language the code is written inPython 3.12 (default), JavaScript (Node 20) or TypeScript (Deno)
CodeYour codeSee the hints below
Dependencies (one per line)Packages the code needsFor Python these are pip packages, otherwise npm packages. Placeholders are requests and pandas for Python, lodash and axios otherwise
Output keyThe name the result is stored underDefault code_output
Run in sandbox (isolated)Runs the code in an isolated environmentOn by default

The hint under Code depends on the language:

  • Python: "Function must be named run(input: dict) -> dict".
  • Other languages: "Export default async function run(input)".

A new node starts with this Python code:

def run(input: dict) -> dict:
    # Your logic here
    return {"result": input}

Inputs and outputs

HandleWherePurpose
InputTopThe step that comes before. Its data reaches your function as input
OutputBottomContinues the workflow with the value your function returns, stored under the Output key

The node card shows the chosen language.

Example

This is an illustrative example. You want to add a field to the data.

  1. Keep Language on Python 3.12.
  2. In Code, return a new dictionary built from input, with your extra field.
  3. Read the result in the next step using the Output key, code_output.

Tips

  • Keep the Run in sandbox (isolated) switch on unless you have a reason to turn it off.
  • Name the function exactly as the hint says, or the node will not be able to find it.
  • When you change the language, review the Code box. Changing it does not rewrite the starter code for you, as far as the settings show.