Overview
This node validates a given JSON value against a specified JSON Schema. It is useful in workflows where you need to ensure that input data conforms to a particular structure or set of rules before proceeding with further processing. For example, it can be used to validate API responses, user inputs, or configuration objects to prevent errors downstream.
Properties
| Name | Meaning |
|---|---|
| Value | The JSON data to validate. This should be a valid JSON string or object. |
| Schema | The JSON Schema definition used to validate the "Value". Must be a valid JSON schema. |
Output
The node outputs a JSON array with one object per input item containing either:
validValue: The parsed and validated JSON value if validation succeeds.validationErrors: An array of validation error details if the value does not conform to the schema.providedValue: The original input value when validation fails.
If the input value is not valid JSON, the output contains an object with a validationErrors field indicating "Value is not JSON".
Dependencies
- Uses the
ajvlibrary for JSON Schema compilation and validation. - Uses
ajv-formatsto support additional JSON Schema formats. - Requires no external API keys or services.
- No special environment variables or n8n credentials are needed.
Troubleshooting
- Invalid JSON Schema - failed to parse JSON: The provided schema is not valid JSON. Ensure the schema is correctly formatted as JSON.
- Invalid JSON Schema - ajv compilation failed: The schema is syntactically valid JSON but does not comply with JSON Schema standards or contains unsupported constructs. Review the schema for correctness.
- Value is not JSON: The input value cannot be parsed as JSON. Make sure the input is a valid JSON string or object.
- Validation errors returned by AJV indicate which parts of the input do not match the schema. Use these errors to adjust the input or schema accordingly.