Repair malformed JSON payloads from language models

Generate a bulletproof system prompt that forces language models to output raw, unescaped JSON without conversational wrappers or markdown ticks.

You getSection 1: The System Prompt (ready to copy into an AI action block). Section 2: Before and After Example. Section 3: Verification Steps.

Prompt

Prompt
You are an API integration engineer. Write a system instruction designed to fix and sanitize malformed JSON payloads returned by LLM steps in automation workflows.
- Address common defects: markdown code fences, unescaped quotation marks inside strings, trailing commas, and preamble text.
- Provide an exact system instruction that forces raw, syntactically valid JSON output.
- Include one concrete before-and-after example showing repaired syntax.
Output format: Section 1: The System Prompt (ready to copy into an AI action block). Section 2: Before and After Example. Section 3: Verification Steps.

My problem payload or issue description is below:

Example output

Example for: AI output containing markdown backticks and an unescaped double quote

Section 1: The System Prompt

You are a deterministic data transformation tool. Your sole function is to output valid JSON.

  • Output raw RFC 8259 JSON only.
  • Never include markdown ticks, language identifiers, introductory remarks, or postscripts.
  • Ensure all object keys and string values are enclosed in double quotes.
  • Escape internal quotation marks with backslashes.
  • Remove trailing commas before closing braces or brackets.
    If inputs contain broken syntax, repair the syntax and output only the corrected JSON string.
Section 2: Before and After Example

Before:
Here is the customer data you requested:

{
  "customer": "Acme "Global" Corp",
  "status": "active",
}

Let me know if you need changes!

After:
{"customer":"Acme \"Global\" Corp","status":"active"}

Section 3: Verification Steps
  • Validate that the output string starts strictly with { or [ and terminates with } or ].
  • Pass the payload through a native JSON.parse() step before routing to downstream API webhooks.
Written by AI from this prompt. Your results will vary.

Paste your failing webhook payload or raw AI response directly below this prompt in ChatGPT, Claude, or Gemini. As a follow-up, ask the model to produce a regex-based parser snippet for Make or Zapier as an extra safeguard.

Make it repeatable

Keep using this prompt without pasting it in every time.

Keep exploring

More in Automation & Workflows
Automation & Workflows

Build a schema mapping table between webhooks

Map fields, transform data types, and define fallback values between source and target webhooks. Ideal when connecting two tools with mismatched JSON schemas.