Overview
The "Lenient Structured Output Parser" node is designed to transform and validate AI-generated output into a defined JSON format based on a user-provided JSON Schema. It ensures that the data returned from an AI chain or agent conforms to a specific structure, making it easier to handle downstream in workflows.
This node is particularly useful when integrating AI models that produce free-form text but where structured data output is required for further processing, such as extracting entities, generating reports, or feeding data into databases or APIs.
Practical examples:
- Parsing AI responses about geographical data into a structured object containing states and cities.
- Validating and structuring AI-generated product information before saving it to an inventory system.
- Enforcing consistent output formats from AI agents in multi-step automation workflows.
Properties
| Name | Meaning |
|---|---|
| Connection Hint | Notice to connect this node to either an AI chain or AI agent node. |
| Schema Creation Method | Choose how to define the input schema: - Manual JSON Schema: Write the JSON schema manually. - Generate from Example JSON: Provide example JSON to auto-generate the schema. |
| Example JSON | Example JSON data used to generate the schema automatically (shown only if "Generate from Example JSON" is selected). |
| Input Schema | The JSON Schema manually written by the user to define the expected input structure (shown only if "Manual JSON Schema" is selected). |
| JSON Schema | JSON Schema defining the structure and validation rules for the output data (used in older versions ≤ 2). |
| Notice | Informational message linking to JSON Schema documentation and examples (shown only when manual schema is used). |
Output
The node outputs a JSON object structured according to the provided JSON Schema. This output represents the parsed and validated data extracted from the AI's response, ensuring it matches the expected format.
If the AI output does not conform to the schema, the node will throw an error during parsing.
No binary data output is produced by this node.
Dependencies
- Requires connection to an AI chain or AI agent node to receive raw AI output.
- Uses JSON Schema standards for defining and validating the output structure.
- Internally depends on utilities for converting JSON Schema to Zod schemas and parsing AI output accordingly.
- No external API keys or credentials are directly required by this node itself, but upstream AI nodes may require authentication.
Troubleshooting
- Error during parsing of JSON Schema: This error indicates that the provided JSON Schema is invalid or cannot be processed correctly. To resolve:
- Verify that the JSON Schema is well-formed and follows the official JSON Schema specification.
- If using the "Generate from Example JSON" option, ensure the example JSON is valid and representative of the expected data.
- Output does not match expected structure: Check that the schema accurately reflects the desired output format and that the AI model's output aligns with this schema.
- Node fails to connect or process data: Ensure this node is connected properly to an AI chain or AI agent node as indicated by the connection hint.