🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

n8n-nodes-json-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n8n-nodes-json-parser

n8n node for extracting and parsing JSON from text, including AI model outputs

latest
Source
npmnpm
Version
0.1.5
Version published
Weekly downloads
9
-10%
Maintainers
1
Weekly downloads
 
Created
Source

n8n-nodes-json-parser

npm version License: MIT

An n8n community node for extracting and parsing JSON from text, especially useful for processing AI model outputs that often embed JSON within conversational responses or markdown formatting.

Features

🎯 Multiple Extraction Methods

  • Smart Detection - Automatically finds JSON in various formats
  • First/Last JSON Object - Extract specific occurrences
  • All JSON Objects - Extract multiple JSON structures
  • Between Markers - Custom delimiters (e.g., markdown code blocks)
  • Custom Regex - Advanced pattern matching

đź”§ Intelligent Parsing

  • JSON5 support for relaxed syntax
  • Automatic fixing of common issues:
    • Smart quotes → regular quotes
    • Trailing comma removal
    • Escape sequence correction
  • Schema validation with detailed error messages

🤖 AI-Ready

  • Compatible with AI Agent nodes (usableAsTool: true)
  • Optimized for outputs from:
    • Google Gemini
    • OpenAI GPT
    • Anthropic Claude
    • And other AI models

Installation

  • Navigate to Settings → Community Nodes
  • Click Install a community node
  • Enter: n8n-nodes-json-parser
  • Click Install
  • Restart n8n

Via npm

cd /path/to/n8n
npm install n8n-nodes-json-parser

Docker

Add to your docker-compose.yml:

environment:
  - N8N_COMMUNITY_PACKAGES_ENABLED=true

Then install via UI or exec into container.

Usage

Basic Example

  • Add the JSON Parser node to your workflow
  • Connect it to a node that outputs text (e.g., AI node, HTTP Request)
  • Configure the Source Field (default: {{ $json.text }})
  • Select an Extraction Method (default: Smart Detection)
  • Execute the workflow

Common Use Cases

Extract JSON from AI Response

// Input from Gemini/GPT/Claude:
"Here's the analysis in JSON format:
```json
{
  "sentiment": "positive",
  "score": 0.85,
  "keywords": ["innovation", "growth"]
}

I hope this helps!"

// Output: { "sentiment": "positive", "score": 0.85, "keywords": ["innovation", "growth"] }


#### Fix Malformed JSON
```javascript
// Input with issues:
'{
  "name": "John",
  "age": 30,     // trailing comma
  "city": "NYC",
}'

// Output (with Fix Common Issues enabled):
{
  "name": "John",
  "age": 30,
  "city": "NYC"
}

Extract Multiple JSON Objects

Set Extraction Method to "All JSON Objects" and Output Mode to "New Items":

// Input:
"User 1: {"id": 1, "name": "Alice"}
 User 2: {"id": 2, "name": "Bob"}"

// Output: Two separate items
// Item 1: {"id": 1, "name": "Alice"}
// Item 2: {"id": 2, "name": "Bob"}

Node Parameters

Basic Parameters

ParameterTypeDefaultDescription
Source Fieldstring{{ $json.text }}Expression pointing to the text containing JSON
Extraction MethodselectSmart DetectionHow to find JSON in the text
Output ModeselectReplace InputHow to return the extracted data
On ErrorselectStop WorkflowError handling behavior

Advanced Parameters

ParameterTypeDefaultDescription
Strict ModebooleanfalseOnly accept valid JSON (no fixing)
Fix Common IssuesbooleantrueAuto-fix quotes, commas, etc.
Allow JSON5booleanfalseSupport relaxed JSON5 syntax
JSON Schemajson-Optional schema for validation

Extraction Methods

  • Smart Detection: Automatically detects JSON in markdown, plain text, or mixed content
  • First JSON Object: Finds the first valid {...} structure
  • Last JSON Object: Finds the last valid {...} structure
  • All JSON Objects: Extracts all valid JSON structures
  • Between Markers: Extract between custom delimiters
  • Custom Regex: Use your own regex pattern

Output Modes

  • Replace Input: Returns only the extracted JSON
  • Add to Input: Adds extracted JSON as a new field
  • New Items: Creates separate items for each JSON object

Error Handling Options

  • Stop Workflow: Throws an error and stops execution
  • Continue with Error: Adds error info to output and continues
  • Output Original: Returns the original input unchanged
  • Output Empty: Returns an empty object

Examples

With AI Models

Workflow:
  1. OpenAI Node → Generate structured data
  2. JSON Parser → Extract JSON from response
  3. Postgres Node → Store in database

Data Processing Pipeline

Workflow:
  1. Webhook Node → Receive mixed content
  2. JSON Parser → Extract JSON payload
  3. Transform Node → Process data
  4. HTTP Request → Send to API

Log Processing

Workflow:
  1. Read File → Load log file
  2. Split in Batches → Process line by line
  3. JSON Parser → Extract JSON from each line
  4. Aggregate → Combine results

AI Agent Tool Usage

This node can be used as a tool by AI Agents:

  • Add an AI Agent node to your workflow
  • Connect the JSON Parser node to the Agent's tool input
  • The AI can now extract JSON from any text it processes

The node includes AI-friendly descriptions for all parameters, making it easy for AI models to understand when and how to use it.

Development

Setup

git clone https://github.com/jezweb/n8n-nodes-json-parser.git
cd n8n-nodes-json-parser
npm install
npm run build

Testing

npm link
cd ~/.n8n/custom
npm link n8n-nodes-json-parser
# Restart n8n

Contributing

Pull requests are welcome! Please read our contributing guidelines and ensure:

  • All tests pass
  • Code is linted and formatted
  • Changes are documented

Troubleshooting

Node not appearing in n8n

  • Ensure community nodes are enabled
  • Check n8n version compatibility (>= 1.0.0)
  • Restart n8n after installation

Extraction not working

  • Verify your input contains valid JSON
  • Try different extraction methods
  • Enable "Fix Common Issues" option
  • Check execution logs for detailed errors

Performance issues

  • Use specific extraction methods instead of Smart Detection
  • Limit input size for large datasets
  • Disable schema validation if not needed

Support

License

MIT - See LICENSE file for details

Author

Jeremy Dawes

Acknowledgments

  • n8n team for the excellent workflow automation platform
  • Contributors and users of this node
  • AI community for inspiring this tool's creation

Keywords

n8n-community-node-package

FAQs

Package last updated on 08 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts