Actions74
- ai Actions
- array Actions
- audiovideo Actions
- carbone Actions
- charts Actions
- code Actions
- data Actions
- datetime Actions
- events Actions
- files Actions
- geo Actions
- hellospaces Actions
- images Actions
- Get Metadata of an Image
- Scale an Image
- Overlay an Image on another Image
- Scale an Image to Fit Given Dimensions
- Resize an Image
- Mask an Image with Another Image
- Mask an Image with a Circle Mask
- Crops an image by the given x, y, width and height paramters.
- Convert Texts to an Image
- Convert HTML String or URL to an Image
- Generates a QRCode with given text and color.
- Get EXIF from Image
- Remove EXIF from Image
- Modify Image EXIF
- playground Actions
- spreadsheet Actions
- stripe Actions
- youtube Actions
code → Execute Javascript Code
AI-generatedOverview
This node allows you to execute custom JavaScript code within your n8n workflow. It is particularly useful for scenarios where you need to perform calculations, data transformations, or logic that is not available through standard n8n nodes. For example, you can use this node to manipulate incoming data, filter arrays, or generate dynamic outputs based on complex conditions.
Practical examples:
- Calculating a new field from input data (e.g., sum of two fields).
- Filtering or mapping arrays.
- Formatting dates or strings.
- Any custom logic that can be expressed in JavaScript.
Properties
| Name | Meaning |
|---|---|
| Code | Code to be executed. Has to be valid JavaScript code. Store the result in a variable and just write the variable in a single line at the end to return the value. |
Output
- The output will be the result of the executed JavaScript code, returned as the
jsonfield of the node's output item. - The structure of the output depends entirely on what your code returns. It could be a string, number, object, array, etc.
- If your code throws an error, the output will contain an
errorfield with the error message.
Example output:
{
"json": {
"result": 42
}
}
or, if an error occurs:
{
"json": {
"error": "ReferenceError: x is not defined"
}
}
Dependencies
- Requires a valid API key/credential for "1001fxApi" to be configured in n8n.
- No external services are required for code execution itself, but the node is part of a larger set of functions that may require internet access.
Troubleshooting
Common issues:
- Syntax errors in the provided JavaScript code will cause the node to fail.
- Returning undefined or not returning a value will result in empty output.
- Using unavailable variables or functions will throw reference errors.
Common error messages:
"ReferenceError: ... is not defined": Check your code for typos or missing variable declarations."SyntaxError: Unexpected token ...": Ensure your JavaScript code is valid."Error: Cannot read property ... of undefined": Make sure you are accessing properties on objects that exist.
How to resolve:
- Double-check your JavaScript code for correctness.
- Test your code in a safe environment before using it in the node.
- Use try/catch blocks in your code if you want to handle errors gracefully.