json-extract

n8n node to extract and parse JSON from AI-generated text

Package Information

Downloads: 36 weekly / 72 monthly
Latest Version: 1.1.0
Author: yambal

Documentation

n8n-nodes-json-extract

AI生成テキストから JSON を自動抽出・パースする n8n カスタムノード。完全自動、設定不要。

n8n node to extract and parse JSON from AI-generated text. Fully automatic, zero configuration.

Installation

npm install n8n-nodes-json-extract

Features

  • Automatic pattern detection - Tries multiple extraction patterns and stops at first success:
    1. Markdown code blocks: ```json ... ```
    2. JSON objects: { ... }
    3. JSON arrays: [ ... ]
  • Dual outputs - Success/Fail branches for explicit error handling
  • Fixed output format - Consistent structure across all results
  • Object input support - Pass through already-parsed JSON objects
  • Zero configuration - Only one parameter: Text
  • Duplicate removal - Automatically removes duplicate JSON objects

Output Format

All outputs (Success and Fail) use the same structure:

Success output (Output 1):

{
  "source": "AI response: Here is the user data: {\"name\":\"太郎\",\"age\":30}",
  "isSuccess": true,
  "errorMessage": null,
  "jsons": [
    { "name": "太郎", "age": 30 }
  ],
  "count": 1,
  "first_json": { "name": "太郎", "age": 30 },
  "last_json": { "name": "太郎", "age": 30 },
  "largest_json": { "name": "太郎", "age": 30 }
}
  • isSuccess: true
  • errorMessage: null
  • jsons: Array of extracted JSON objects/arrays
  • count: Number of extracted JSONs
  • first_json: First extracted JSON (or null if none)
  • last_json: Last extracted JSON (or null if none)
  • largest_json: Largest JSON by string size (or null if none)

Fail output (Output 2):

{
  "source": "No JSON found in this text",
  "isSuccess": false,
  "errorMessage": "No valid JSON found in text",
  "jsons": [],
  "count": 0,
  "first_json": null,
  "last_json": null,
  "largest_json": null
}
  • isSuccess: false
  • errorMessage: Error description
  • jsons: []
  • count: 0
  • All extra fields are null

Usage

  1. Add the "JSON Extract" node to your workflow
  2. Connect text input from AI agents (Claude, ChatGPT, Gemini, etc.)
  3. Enter text or use expressions like {{ $json.output }}
  4. Connect Success/Fail outputs to different branches

Example workflow:

AI Agent → JSON Extract → [Success] → Process Data
                       → [Fail] → Error Handler

Use Cases

  • Extract JSON from AI chat responses
  • Parse structured data from unstructured text
  • Handle AI output with mixed text and JSON
  • Extract multiple JSON objects from single response

Version History

  • v1.1.0 - Added convenience fields: count, first_json, last_json, largest_json
  • v1.0.0 - Automatic pattern detection, zero configuration
  • v0.6.0 - Removed Extraction Mode parameter
  • v0.5.0 - Fixed output format
  • v0.4.0 - Removed On Parse Error parameter
  • v0.3.0 - Added Success/Fail dual outputs
  • v0.2.0 - Changed to direct text input

License

MIT

Discussion