# Parse malformed JSON from text with escaping and quote correction
This workflow solves the common problem of processing invalid JSON that often appears in AI model outputs, logs, or free-text user input. It takes a text string containing partially structured data and converts it into valid JSON suitable for further use in n8n or other systems.
## Who it´s for
- Developers integrating AI responses into their systems
- Analysts processing structured data from uncleaned sources
- Automation engineers dealing with malformed JSON in API responses
## What the automation does
- Accepts a text string with potentially invalid JSON (e.g., from an AI)
- Removes Markdown fences (```
json...```), if present
- Fixes common syntax issues: character escaping, trailing commas, duplicate quotes
- Attempts to parse JSON; on failure, extracts balanced { } or [ ] blocks
- Outputs clean structured data for downstream processing
## What´s included
- Ready-to-use n8n workflow
- Trigger and input handling logic
- Integrations built using JavaScript and n8n’s native JSON parser
- Basic textual instructions for launch and adaptation
## Requirements for setup
- An n8n account (self-hosted or cloud)
- Ability to edit workflows and execute JavaScript code in nodes
## Benefits and outcomes
- Reliable parsing of ´dirty´ JSON without manual cleanup
- Reduced failures in automation chains due to formatting errors
- Direct use of AI-generated output in workflows
- Automatic extraction even from heavily malformed fragments
## Important: template only
Important: you are purchasing a ready-made automation workflow template only. Rollout into your infrastructure, connecting specific accounts and services, 1:1 setup help, custom adjustments for non-standard stacks and any consulting support are provided as a separate paid service at an individual rate. To discuss custom work or 1:1 help, contact via chat
No feedback yet