JSON Schema Validator

Validates a JSON object against a JSON schema

Overview

This node validates a JSON object against a provided JSON schema. It is useful in workflows where you need to ensure that incoming data conforms to a specific structure or set of rules before further processing. For example, it can be used to validate API responses, user inputs, or configuration objects to prevent errors downstream.

Properties

Name Meaning
JSON Object The JSON object to validate. This is the data you want to check against the schema.
JSON Schema The JSON schema to validate against. Defines the expected structure and constraints.

Output

The node outputs the original input data with additional fields appended to the json property:

  • isValid: A boolean indicating whether the JSON object passed validation (true) or not (false).
  • errors: An array containing validation error details if the JSON object does not conform to the schema; empty if valid.

If an error occurs during validation and the node is configured to continue on failure, the output for that item will contain an error field describing the issue.

Dependencies

  • Uses the ajv library for JSON schema validation.
  • Requires no external API keys or services.
  • No special environment variables or n8n configurations are needed beyond standard node setup.

Troubleshooting

  • Common issues:
    • Invalid JSON schema format may cause compilation errors.
    • Input JSON object not matching the schema will result in validation errors listed in the output.
  • Error messages:
    • Validation errors are detailed in the errors output field.
    • If the node throws an error (e.g., due to invalid schema), enabling "Continue On Fail" allows the workflow to proceed while capturing the error message in the output.

Links and References

Discussion