Actions40
- AI Actions
- Business Actions
- Calculate Actions
- Code Actions
- Convert Actions
- Crypto Actions
- Generate Actions
- Operator Actions
- PDF Actions
- Storage Actions
Overview
The CodeKit node with the Resource: Code and Operation: Javascript allows users to execute custom JavaScript code within an n8n workflow. This is particularly useful for scenarios where you need to perform data transformations, calculations, or logic that isn't covered by standard n8n nodes. For example, you might use this node to manipulate incoming JSON data, filter arrays, or generate dynamic values based on workflow input.
Practical examples:
- Transforming API response data before passing it to another service.
- Calculating new fields from existing input data.
- Filtering or mapping arrays of objects.
Properties
| Name | Meaning |
|---|---|
| Code | Your javascript code |
Output
- The output will be a JSON object (or array of objects) resulting from the execution of your provided JavaScript code.
- The structure of the output depends entirely on what your code returns or modifies.
- If your code throws an error and "Continue On Fail" is enabled, the output will include an
errorfield with the error message.
Example output:
[
{
"result": "your computed value"
}
]
or, in case of error:
[
{
"error": "Error: ReferenceError: x is not defined"
}
]
Dependencies
- Requires the CodeKit API credential to be configured in n8n.
- No external services are required for the Javascript operation itself, but the node infrastructure expects the credential to be present.
Troubleshooting
Common issues:
- Syntax errors in JavaScript code: If your code contains syntax errors, the node will throw an error. Check your code carefully for typos or missing characters.
- Reference errors: Using undefined variables or functions will result in errors.
- Missing credentials: The node requires the CodeKit API credential, even though it's not used for the Javascript operation. Ensure it's set up in n8n.
Error messages:
"Error: ReferenceError: ..."– Indicates a problem in your JavaScript code. Review the code for mistakes."Cannot read property '...' of undefined"– You're trying to access a property on something that's not defined. Add checks or ensure the variable exists.
How to resolve:
- Test your JavaScript 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.