Overview
The Process Spawn Node allows you to execute system commands as child processes from within an n8n workflow. It supports passing arguments, environment variables, custom working directories, and input via stdin. The node can parse the command's output as either JSON or plain text. This node is useful for integrating external scripts, utilities, or system-level operations into your automation workflows.
Practical examples:
- Running shell scripts or CLI tools and processing their output in n8n.
- Automating file management tasks (e.g.,
ls,cp,mv). - Invoking custom data processing scripts and capturing their results.
- Integrating with legacy systems via command-line interfaces.
Properties
| Name | Type | Meaning |
|---|---|---|
| Command | string | The system command to execute (e.g., ls, python, echo). |
| Args | fixedCollection | List of arguments to pass to the command. Each argument is a string. |
| Envs | fixedCollection | List of environment variables to set for the process. Each has a Name and Value. |
| Stdin | string | Data to send to the process's standard input. Defaults to the input item's JSON if empty. |
| Working Dir | string | Optional working directory in which to run the command. |
| StdoutFormat | options | How to parse the command's standard output: "JSON" (parse as JSON) or "Plain" (raw text). |
Output
- If the command executes successfully:
- When StdoutFormat is set to JSON:
- The node parses the command's stdout as JSON and sets it as the output item's
jsonfield. - If stdout is empty, outputs an empty object (
{}).
- The node parses the command's stdout as JSON and sets it as the output item's
- When StdoutFormat is set to Plain:
- The node outputs an object with a single property:
{ "stdout": "<command output as string>" }
- The node outputs an object with a single property:
- When StdoutFormat is set to JSON:
- If the command fails:
- Throws an error containing both stdout and stderr content.
- If "Continue On Fail" is enabled, attaches the error and original input to the output.
Dependencies
- Node.js: Relies on the Node.js runtime to spawn child processes.
- n8n: Must be running in an environment where the desired system commands are available.
- No external API keys required.
Troubleshooting
Common issues:
Command not found:
Error if the specified command does not exist in the system's PATH.
Resolution: Ensure the command is installed and accessible.Invalid JSON output:
If StdoutFormat is set to JSON but the command outputs invalid JSON, parsing will fail.
Resolution: Check that the command outputs valid JSON when expected.Permission denied:
Errors may occur if the process lacks permission to execute the command or access the working directory.
Resolution: Verify permissions for the user running n8n.Error message example:
[stdout] <stdout content> [stderr] <stderr content>Resolution: Review the stderr output for clues about the failure.