Overview
This node provides a simple key-value storage mechanism using JSON files. It allows users to save a value under a specific key or read a value by its key from a file. This is useful for scenarios where you want to persist small amounts of data between workflow executions without setting up an external database or service.
Practical examples include:
- Caching API tokens or session data locally.
- Storing configuration flags or counters that need to be retained across runs.
- Saving temporary data generated in one part of a workflow to be used later.
Properties
| Name | Meaning |
|---|---|
| File | The name of the JSON file where key-value pairs are saved or read from. |
| Key | The key identifier for the value to save or retrieve. |
| Value | The string value to save under the specified key. Required only when performing a save. |
Output
The node outputs a single JSON object with the following structure depending on the operation:
Save Operation:
{ "<key>": { "value": "<saved_value>", "operation": "save", "status": "Saved" } }This confirms the key and value were saved successfully.
Read Operation:
{ "key": "<key>", "value": "<retrieved_value_or_null>", "operation": "read" }Returns the value associated with the key, or
nullif the key does not exist.
No binary data output is produced by this node.
Dependencies
- Uses Node.js built-in
fs(filesystem) andpathmodules to read/write JSON files. - Stores data in a subdirectory named
datarelative to the node's source code directory. - No external services or API keys are required.
Troubleshooting
- File Access Issues: If the node cannot create or write to the
datadirectory or JSON file, ensure the n8n process has appropriate filesystem permissions. - Corrupted JSON File: Manual edits or concurrent writes might corrupt the JSON file, causing parse errors. Deleting or fixing the file may resolve this.
- Missing Key on Read: Reading a non-existent key returns
null. Confirm the key was saved previously. - Invalid Input: Ensure all required properties (
File,Key, and for save operation,Value) are provided; otherwise, the node will error out.