Skip to main content

Json string validator via webhook

Workflow preview

Workflow preview
100%
Json string validator via webhook preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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 ...

Best for

  • Engineering automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.respondtowebhook, n8n-nodes-base.code, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by ist00dent.

Original n8n.io source

1.1 Workflow description

Title
Json string validator via webhook
Workflow name
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 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.


πŸ‘€ Who is it for?

This workflow is ideal for:

  • Developers & Integrators: Pre-validate JSON payloads from external systems (APIs, webhooks) before processing them in your workflows, preventing errors.
  • Data Engineers: Ensure the integrity of JSON data before storing it in databases or data lakes.
  • API Builders: Offer a dedicated endpoint for clients to test their JSON strings for validity.
  • Customer Support Teams: Quickly check user-provided JSON configurations for errors.
  • Anyone handling JSON data: A quick and easy way to programmatically check JSON string correctness without writing custom code in every application.

πŸ“‘ 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

  • Import Workflow:

    • In your n8n editor, click "Import from JSON" and paste the provided workflow JSON.
  • Configure Webhook Path:

    • Double-click the Webhook node.
    • In the 'Path' field, set a unique and descriptive path (e.g., /validate-json).
  • Activate Workflow:

    • Save and activate the workflow.

πŸ“ Tips

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

  • Enhanced Error Feedback:

    • Upgrade: Add a Set node after the Code node to format the error message into a more user-friendly string before responding.
    • Leverage: Make it easier for the caller to understand the issue.
  • Logging Invalid Inputs:

    • Upgrade: After the Code node, add an IF node to check if valid is false. If so, branch to a node that logs the invalid jsonString and error to a Google Sheet, database, or a logging service.
    • Leverage: Track common invalid inputs for debugging or improvement.
  • Transforming Valid JSON:

    • Upgrade: If the JSON is valid, you could add another Function node to parse the jsonString and then operate on the parsed JSON data directly within the workflow.
    • Leverage: Use this validator as the first step in a larger workflow that processes JSON data.
  • Asynchronous Validation:

    • Upgrade: For very large JSON strings or high-volume requests, consider using a separate queueing mechanism (e.g., RabbitMQ, SQS) and an asynchronous response pattern.
    • Leverage: Prevent webhook timeouts and improve system responsiveness.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Webhook: Receive JSON String

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 2 - Respond to Webhook with Result

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.2

Block 3 - Code: Validate JSON String

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - Note: Webhook Input

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Note: JSON Validation Logic

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Note: Webhook Response

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Json string validator via webhook
Complexity intermediate
Nodes 6
Categories Engineering
Author ist00dent
Published 05 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4704/4704.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Json string validator via webhook do?

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 ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.