Overview
This node writes content to a file on the filesystem. It supports multiple content sources including direct text input, base64-encoded binary data, binary data from previous nodes, JSON objects, or content extracted from a property of the input data. The node allows flexible write modes such as overwriting existing files, appending to them, or creating new files only if they do not exist. Additional options include creating parent directories automatically, setting file permissions, formatting JSON output, and optionally backing up existing files before overwriting.
Common scenarios where this node is useful include:
- Saving generated reports or logs as text files.
- Writing image or other binary data received from previous workflow steps.
- Exporting structured data as formatted JSON files.
- Appending incremental data to existing files for audit trails or continuous logging.
- Creating configuration files dynamically during automation workflows.
Practical example:
- After processing some data, you want to save a summary report as a nicely formatted JSON file on disk.
- You receive an image in binary form from an API call and want to save it as a PNG file.
- You want to append new log entries to a daily log file without overwriting previous content.
Properties
| Name | Meaning |
|---|---|
| File Path | The full path where the file should be written. |
| Content Source | The source of the content to write. Options: Text Input, Binary Data (base64 encoded), Input Binary Field (from previous node), JSON Object (formatted text), From Property (content from input data property). |
| Content | The text content to write to the file (used when Content Source is "Text Input"). |
| Binary Data (Base64) | Base64 encoded binary data to write (used when Content Source is "Binary Data"). |
| Binary Field Name | Name of the binary field from the previous node to use as content (used when Content Source is "Input Binary Field"). |
| JSON Object | JSON object to write as formatted text (used when Content Source is "JSON Object"). |
| Property Name | Name of the property containing the content to write (used when Content Source is "From Property"). |
| Write Mode | How to write the file. Options: Overwrite (replace existing or create new), Append (add to existing or create new), Create Only (fail if file exists). |
| Encoding | Encoding used when writing the file (applies to Text Input, JSON Object, and From Property). Options: UTF-8, ASCII, UTF-16 LE, Base64, Hex. |
| Additional Options | Collection of extra settings: • Create Parent Directories (boolean): Whether to create missing parent directories. • File Mode (Permissions): File permissions in octal notation (e.g., 0644). • JSON Formatting: Pretty (indented) or Compact (for JSON Object). • Backup Existing File (boolean): Whether to create a backup copy before overwriting an existing file. |
Output
The node outputs one item per input with a JSON object containing metadata about the file write operation:
success: Boolean indicating if the write was successful.filePath: The resolved absolute path of the written file.fileName: The base name of the file.fileExtension: The file extension.writeMode: The mode used to write the file (overwrite, append, create).contentSource: The source type of the content written.bytesWritten: Number of bytes written to the file.sizeHuman: Human-readable file size (e.g., "1.23 MB").created: File creation timestamp.modified: File modification timestamp.encoding: (If applicable) The encoding used for text-based content.binaryFieldName: (If applicable) The binary field name used when writing binary data from input.
If the node encounters an error and "Continue On Fail" is enabled, the output will contain success: false and an error message describing the failure.
Dependencies
- Requires access to the local filesystem where n8n is running.
- Uses Node.js built-in modules:
fsfor file operations andpathfor resolving file paths. - No external API keys or services are required.
- Permissions to create/write files and directories at the specified paths must be granted to the n8n process.
Troubleshooting
- File path is required: Ensure the "File Path" property is set and valid.
- File already exists and write mode is 'create only': Change write mode or delete existing file.
- Property not found in input data: When using "From Property" content source, verify the property name exists in the input JSON.
- Permission denied errors: Check that n8n has sufficient permissions to write to the target directory and create parent directories if enabled.
- Invalid content source: Confirm the selected content source matches the provided content properties.
- Backup creation fails: If backup option is enabled but fails, ensure there is enough disk space and write permissions.
- For binary data from previous nodes, ensure the binary field name is correct and the previous node outputs binary data.