⚒️ Json string validator via webhook

2,151 views · ⚒️ Engineering

Description

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


👤 Who is it for?

This workflow is ideal for:


📑 Data Structure

When you trigger the webhook, send a POST request with a JSON body structured as follows:

{
  "jsonString": "{\"name\": \"n8n\", \"type\": \"workflow\"}"
}

Example of an invalid JSON string:

{
  "jsonString": "{name: \"n8n\"}" // Missing quotes around 'name'
}

The workflow will return a JSON response indicating validity:

For a valid JSON string:

{
  "valid": true
}

For an invalid JSON string:

{
  "valid": false,
  "error": "Unexpected token 'n', \"{name: \"n8n\"}\" is not valid JSON"
}

⚙️ Setup Instructions


📝 Tips

This JSON validator workflow is a solid starting point. Consider these enhancements:

🔗 Nodes Used

Webhook

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup