npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-json-storage

v0.1.6

Published

n8n node for storing and retrieving key-value pairs in a JSON file

Readme

n8n-nodes-json-storage

This is an n8n community node for storing and retrieving key-value pairs in a JSON file.

Features

  • Save key-value pairs in a JSON file
  • Read values by key from the JSON file
  • Values are stored in base64 format for security
  • Simple and easy to use
  • Custom file path support
  • Consistent JSON output format

Operations

Save

Saves a key-value pair to the JSON file. If the key already exists, its value will be updated.

Parameters:

  • Key: The key to save
  • Value: The value to save
  • File Path: Full path to the JSON file where data will be stored

Output format:

{
  "success": true,
  "key": "your-key",
  "value": "your-value"
}

Read

Reads a value by key from the JSON file.

Parameters:

  • Key: The key to retrieve
  • File Path: Full path to the JSON file where data is stored

Output format (key found):

{
  "success": true,
  "key": "your-key",
  "value": "stored-value"
}

Output format (key not found):

{
  "success": false,
  "key": "your-key",
  "value": ""
}

Installation

Follow these steps to install this node in your n8n instance:

  1. git clone ...
  2. npm pack
  3. upload or copy in your n8n installation user ".n8n/custom" directory For example if your user is www-data this directory will be: ~www-data/.n8n/custom
  4. Run the following command:
    npm install n8n-nodes-json-storage
  5. Restart n8n

Usage Examples

Save a value

  1. Create a new workflow
  2. Add a "JSON Storage" node
  3. Select the "Save" operation
  4. Enter a key and a value
  5. Configure the file path (default is [working-directory]/data/custom_json.json)
  6. Execute the node

Read a value

  1. Create a new workflow
  2. Add a "JSON Storage" node
  3. Select the "Read" operation
  4. Enter the key to retrieve
  5. Ensure the file path matches the one used for saving
  6. Execute the node

Notes

  • By default, data is stored in a "data" directory in your specified path
  • Directories will be created automatically if they don't exist
  • Values are encoded in base64 before saving to the file
  • The operation will fail if the JSON file exists but has invalid format

Developer Notes

Managing the "this" context in JavaScript

When developing n8n nodes, it's important to understand how the this context works in JavaScript.

Problem

The error this.someMethod is not a function typically occurs when a method loses its binding to the class instance. This happens in the following scenarios:

  1. When methods are passed as callbacks
  2. When methods are called from a different context
  3. When using separated method implementations that rely on the class context

Solutions

There are several ways to solve this issue:

  1. Inline implementation: Define the logic directly in the main method (like we did in v0.1.4)

    async execute() {
      // Implement logic directly here instead of in separate methods
    }
  2. Bind methods in constructor:

    constructor() {
      this.saveOperation = this.saveOperation.bind(this);
      this.readOperation = this.readOperation.bind(this);
    }
  3. Use arrow functions (which preserve the lexical this):

    saveOperation = async (items, returnData, storage, filePath) => {
      // Method implementation
    }
  4. Pass this explicitly:

    await this.saveOperation.call(this, items, returnData, storage, filePath);

For n8n nodes, the safest approach is either using inline implementations or explicitly binding methods in the constructor.

Version History

  • 0.1.6 - Standardized JSON output format for both save and read operations
  • 0.1.5 - Simplified read output when key is not found
  • 0.1.4 - Fixed "this.readOperation is not a function" error by implementing functions inline
  • 0.1.3 - Added custom file path support, automatic directory creation
  • 0.1.2 - Added working directory and home directory information
  • 0.1.1 - Fixed compatibility issues
  • 0.1.0 - Initial release