JSON Storage 0.1.6 icon

JSON Storage 0.1.6

Store and retrieve key-value pairs in a JSON file

Actions2

Overview

This node provides a simple key-value storage mechanism using a JSON file on the local filesystem. It allows users to save string values under specified keys or read values by keys from the JSON file. Values are stored as base64 encoded strings to preserve data integrity.

Common scenarios include:

  • Persisting small amounts of configuration or state data between workflow executions.
  • Sharing data between different parts of a workflow or across workflows without external databases.
  • Quick prototyping where lightweight persistent storage is needed without setting up external services.

For example, you can save an API token under a key and later retrieve it in another workflow step, or store user preferences that need to be reused.

Properties

Name Meaning
Operation Choose between "Save" (store a key-value pair) or "Read" (retrieve a value by key).
Key The identifier string used to save or retrieve a value.
Value The string value to save under the specified key (only for Save operation).
File Path Full path to the JSON file where data is stored. The directory will be created if missing.
Info Notice indicating that values are stored as base64 encoded strings in the JSON file.

Output

The node outputs an array of JSON objects, one per input item processed, each containing:

  • success (boolean): Indicates whether the operation succeeded for the given key.
  • key (string): The key used in the operation.
  • value (string): For "save", this echoes the saved value; for "read", this contains the retrieved value or an empty string if not found.
  • error (string, optional): Present only if an error occurred and the node is configured to continue on failure.

No binary data output is produced by this node.

Example output for a successful save:

{
  "success": true,
  "key": "myKey",
  "value": "myValue"
}

Example output for a failed read (key not found):

{
  "success": false,
  "key": "unknownKey",
  "value": ""
}

Dependencies

  • Requires access to the local filesystem to read/write the JSON file.
  • No external APIs or services are required.
  • The node ensures the directory for the JSON file exists, creating it if necessary.
  • No special environment variables or credentials are needed.

Troubleshooting

  • File Access Errors: If the node cannot read or write the JSON file, ensure the file path is correct and the n8n process has appropriate filesystem permissions.
  • Invalid JSON Format: If the JSON file is manually edited and corrupted, parsing errors may occur. Fix the JSON format or delete the file to reset.
  • Base64 Encoding Issues: Values are stored as base64 strings. If you manually edit the file, ensure values remain valid base64 strings to avoid decoding errors.
  • Concurrent Writes: Running multiple instances of this node writing to the same file simultaneously may cause race conditions or data loss. Use with caution in parallel workflows.
  • Error Handling: If an error occurs during execution, the node throws an error unless configured to continue on failure, in which case it outputs an error message in the result.

Links and References

Discussion