Json string validator via webhook
This n8n template provides a simple yet powerful utility for validating if a given string input is a valid JSON format. You can use this to pre-validate data received from external sources, ensure data integrity befor...
Template notes
This n8n template provides a simple yet powerful utility for validating if a given string input is a valid JSON format. You can use this to pre-validate data received from external sources, ensure data integrity before further processing, or provide immediate feedback to users submitting JSON strings.
---
🔧 How it works - Webhook: This node acts as the entry point for the workflow, listening for incoming POST requests. It expects a JSON body with a single property:
- jsonString: The string that you want to validate as JSON.
- Code (JSON Validator): This node contains custom JavaScript code that attempts to parse the jsonString provided in the webhook body.
- If the jsonString can be successfully parsed, it means it's valid JSON, and the node returns an item with valid: true. - If parsing fails, it catches the error and returns an item with valid: false and the specific error message. - This logic is applied to each item passed through the node, ensuring all inputs are validated.
- Respond to Webhook: This node sends the validation result (either valid: true or valid: false with an error message) back to the service that initiated the webhook request.
---