API Endpoint for Real-Time JSON String Validation - n8n Workflow

Learn how to build a custom API endpoint using this n8n workflow template to instantly validate incoming JSON strings. This n8n node setup ensures data integrity for external systems.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers and engineers needing a reliable external JSON validation service.
Users integrating legacy systems where input format verification is critical.
n8n users looking for advanced examples of using the Code n8n node for data processing.
Automation specialists seeking reusable n8n templates for core logic validation.

Overview

This specialized n8n workflow provides an instant, dedicated API endpoint for verifying data structure integrity. Instead of writing custom microservices purely for JSON validation, you can deploy this simple n8n template. When an external system sends a string via POST request, the n8n trigger immediately captures it. The core logic uses a custom Code n8n node to attempt parsing the input. This is critical for ensuring that any data flowing into sensitive systems (like databases or other APIs) is correctly formatted JSON, preventing runtime errors and improving data quality. This n8n workflow is a powerful utility for DevOps and data integration tasks.

How it Works

This automation starts with a dedicated n8n trigger, the Webhook n8n node.


  1. Receive Data: The Webhook n8n node listens for an incoming HTTP POST request at the specified path (validate-json-string). It expects the payload to contain a jsonString property.

  2. Validate String: The process moves to the Code n8n node. This crucial n8n node executes custom JavaScript. It attempts to JSON.parse() the incoming jsonString.

  3. Handle Results: If the parsing is successful, the Code n8n node outputs a { valid: true } object. If parsing fails (meaning the string is malformed or not valid JSON), or if the expected input property is missing, it catches the error and outputs { valid: false, error: ... }.

  4. Respond: Finally, the Respond to Webhook n8n node takes the validation object (the output of the Code node) and immediately sends it back to the system that initiated the request. This provides instantaneous validation feedback, making this n8n workflow ideal for real-time integrations.

Installation Guide

To deploy this n8n workflow, follow these steps:


  1. Import: Copy the provided JSON string and import it directly into your n8n instance via the 'New' menu -> 'Import from JSON'.

  2. Webhook Configuration: The Webhook: Receive JSON String n8n trigger is already configured. Save the workflow. Once saved and activated, n8n will provide a unique URL for this webhook.

  3. Activation: Ensure the n8n workflow is active (toggle the switch in the top right corner).

  4. Testing: Send an HTTP POST request to the generated webhook URL (with the /validate-json-string path) containing a body like {"jsonString": "{\"key\": \"value\"}"} to test a valid string, and {"jsonString": "{key: value}"} to test an invalid one. This simple n8n template is ready to use without external credentials.

Node Details

Webhook: Receive JSON String (n8n trigger)
Function: Acts as the starting point (n8n trigger) and the API endpoint for this n8n workflow.
Key Configuration: Method is set to POST. Path is /validate-json-string. Response Mode is responseNode to allow the final node to control the output.

Code: Validate JSON String (n8n node)
Function: Contains the custom JavaScript logic necessary to validate the input string.
Key Configuration: The code attempts JSON.parse() on the jsonString property from the incoming webhook body. It handles missing input and parsing errors, returning a clear valid: true or valid: false status.

Respond to Webhook with Result (n8n node)
Function: Sends the output generated by the validation Code n8n node back to the requesting system.
* Key Configuration: Responds with allIncomingItems, which includes the validation object (valid status and error message, if applicable).

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by
ist00dent
ist00dent

I’m a dedicated automation engineer passionate about no-code and low-code solutions. I design and implement robust n8n workflows—integrating APIs, databases, and messaging—to eliminate manual tasks and accelerate delivery. Leveraging Python and C#, I build scalable, adaptable automations that empower teams to focus on high-value work.

Featured*