This is a community node for n8n that provides an advanced output parser with dynamic expression support. It extends the functionality of the standard LangChain output parser by allowing you to use n8n expressions to dynamically create and modify JSON schemas at runtime.
- Dynamic Expression Support: Use n8n expressions in JSON schemas and examples
- Multiple Schema Modes:
- Static JSON Schema
- Generate from JSON example with expressions
- Fully dynamic schemas using expressions
- Auto-Fix Functionality: Automatically retry parsing with LLM assistance when output doesn't match schema
- Expression-Powered: Leverage workflow data to create context-aware schemas
- Backward Compatible: Works with existing static schemas
To install this community node, you have several options:
- Go to Settings > Community Nodes in your n8n interface
- Enter
n8n-nodes-advanced-output-parser
in the npm package name field - Click Install
# In your n8n installation directory
npm install n8n-nodes-advanced-output-parser
Add the package to your n8n Docker environment:
FROM n8nio/n8n
USER root
RUN npm install -g n8n-nodes-advanced-output-parser
USER node
- Add the Node: Search for "Advanced Output Parser" in the node palette
- Connect to LangChain: Connect it to any LangChain chain or agent node
- Configure Schema Mode: Choose how you want to define your schema:
- Static: Use a fixed JSON schema
- From Example: Generate schema from a JSON example
- Dynamic: Use expressions to build schemas from workflow data
Use a traditional, fixed JSON schema:
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "number" }
}
}
Generate schema from JSON examples that can include expressions:
{
"user": "{{ $json.username }}",
"preferences": ["{{ $json.defaultPreference }}"],
"metadata": {
"source": "{{ $node.name }}"
}
}
Build entire schemas using expressions:
{{
$json.userType === 'admin' ?
{
"type": "object",
"properties": {
"adminData": {"type": "object"},
"permissions": {"type": "array"}
}
} :
{
"type": "object",
"properties": {
"userData": {"type": "object"}
}
}
}}
- Multi-tenant Applications: Different schemas for different tenants
- API Response Parsing: Handle varying API response structures
- Dynamic Form Processing: Process forms with different field sets
- Context-Aware Data Extraction: Extract different data based on workflow context
- Conditional Output Formatting: Format output differently based on input data
{
{
$json.responseType === "user" ? $json.userSchema : $json.productSchema;
}
}
{{
{
"type": "object",
"properties": Object.fromEntries(
$json.fields.map(field => [
field.name,
{"type": field.type, "description": field.description}
])
)
}
}}
{
{
$json.customSchema || $parameter.defaultSchema;
}
}
Option | Description |
---|---|
Schema Mode | How to define the output schema (Static/From Example/Dynamic) |
JSON Schema | The JSON schema definition (supports expressions) |
JSON Example | Example JSON to generate schema from (supports expressions) |
Make All Fields Required | Whether generated schemas should make all fields required |
Auto-Fix Format | Automatically retry parsing with LLM when format is incorrect |
Custom Prompt | Custom prompt for auto-fix functionality |
When enabled, the auto-fix feature will:
- Attempt to parse the LLM output with your schema
- If parsing fails, automatically generate a retry prompt
- Send the retry prompt to the connected LLM
- Parse the corrected response
This is especially useful for complex schemas where the LLM might need guidance.
To contribute to this project:
# Clone the repository
git clone https://github.com/volkovmqx/n8n-nodes-advanced-output-parser.git
# Install dependencies
cd n8n-nodes-advanced-output-parser
npm install
# Build the project
npm run build
# Link for local development
npm link
- n8n version 1.0.0 or higher
- Node.js 18.10 or higher
@langchain/core
: LangChain core functionalitylangchain
: LangChain output parserszod
: Schema validationgenerate-schema
: JSON schema generationjson-schema
: JSON Schema types
MIT
For issues, questions, or contributions:
- GitHub Issues: https://github.com/volkovmqx/n8n-nodes-advanced-output-parser/issues
- n8n Community: https://community.n8n.io
- Initial release
- Dynamic expression support for JSON schemas
- Multiple schema modes (Static, From Example, Dynamic)
- Auto-fix functionality
- Full backward compatibility with standard output parsers
Made with ❤️ from Leipzig for the n8n community