AI and LLM JSON
JSON from AI Models: Why It Breaks and How to Fix It
Language models break JSON in a handful of repeatable ways: markdown fences, Python literals, trailing commas, truncated streams and schema drift. Each provider has its own pattern; the guides below name the pattern and the repair, and the tool fixes all of them in one pass.
ChatGPT and OpenAI
JSON mode guarantees syntax, not your schema; structured outputs guarantee the schema, not every model supports it.
- Fix ChatGPT JSON Errors: The Complete GuideChatGPT often returns malformed JSON with trailing commas, single quotes, or markdown fences. Learn exactly what goes wrong and how to fix it automatically.11 min read
- OpenAI JSON Mode vs Structured Outputs: Handling JSON Parse ErrorsCompare OpenAI JSON mode and structured outputs. Learn when JSON.parse() fails, why it happens, and how to repair broken JSON in production.6 min read
- o3-mini Structured Output: JSON Limitations and Fixes (2026)o3-mini doesn't support json_schema response format like GPT-4o. Learn the actual limitations, workarounds, and when to use reasoning models for structured JSON output.8 min read
- OpenAI DevDay 2026: Dots, the Agents API, and Why JSON Repair Matters More Than EverOpenAI DevDay 2026 announced Dots (always-on agents with persistent MCP connections), the Agents API, and Plugin Extensions. Every one of these produces more LLM-generated JSON in production. Here's what that means for reliability.12 min read
Claude and Anthropic
Most Claude JSON failures are 400 errors from the tool schema or the request shape, not from the model's text.
- Getting Reliable JSON from Claude API: Complete Guide to Structured OutputClaude API returning malformed JSON? Learn how to prompt Claude for reliable JSON, handle edge cases, and repair output automatically.10 min read
- Claude Tool Use for JSON Output: Complete 2026 Guide (Structured Outputs vs Tool Use)Master Claude's tool use and native structured outputs for reliable JSON. Covers output_config.format, strict tool use, schema limitations, and repair fallback for edge cases.12 min read
- How to Fix Claude API 400 Errors in JSON Tool Calls (2026)Claude API returning 400 errors during tool_use or tool_result calls? This guide covers all 5 root causes — orphaned tool blocks, context compression, concurrent execution, beta header mismatch, and schema key violations — with Python and TypeScript fixes.10 min read
- Fix Claude Haiku 4.5 invalid_tool_call_format Errors (2026 Guide)Claude Haiku 4.5 throwing invalid_tool_call_format or 400 errors in tool_use calls? This guide covers all 5 root causes — schema violations, orphan tool_result blocks, context compaction, concurrent calls, and control characters — with Python and TypeScript fixes.12 min read
- Claude Prefill Deprecated: Fix Your JSON Scaffolding (Sonnet 4.6 / Opus 4.6)Prefill removed in Claude Sonnet 4.6, Opus 4.6, and Opus 4.7. If your JSON scaffolding is throwing 400 errors or returning broken output, here's the migration path using output_config.format with full code examples.12 min read
- Claude Sonnet 4 Retiring June 15: How to Migrate Your JSON Pipeline TodayClaude Sonnet 4 and Opus 4 retire June 15, 2026. API calls will fail immediately. Here's the exact JSON migration checklist — model string updates, output behavior differences, and how to test your pipeline before Monday.7 min read
- Anthropic Batch API for JSON Processing: 50% Off, High Volume (2026 Guide)The Anthropic Message Batches API processes up to 100,000 JSON requests asynchronously at 50% off standard pricing. Learn when to use it, how to structure JSONL payloads, handle malformed outputs, and build reliable batch JSON pipelines in 2026.9 min read
- Anthropic Tool Schema Validation Errors: 7 Patterns That Return 400 (2026)Claude Code v2.0.21+ strict MCP schema validation breaks working tools. This guide covers every 400 error pattern — oneOf/allOf/anyOf, $schema property key, invalid $ref, strict field, outputSchema — and gives the exact fix for each.13 min read
- Anthropic Workbench Deprecated: Migrate Your Structured Output Workflow (2026)Anthropic retired the Claude Workbench and 3 experimental prompt API endpoints on August 17, 2026. Here's what broke, what you lost, and how to migrate your structured output workflow to code.12 min read
- Fix Vercel AI SDK JSON Schema Errors with Anthropic (2026)Getting 400 errors from Anthropic when using Vercel AI SDK structured output? Unsupported JSON Schema keywords like exclusiveMinimum, minItems, and not are silently breaking your schema. Here's the fix.8 min read
Gemini, DeepSeek and local models
Smaller and self-hosted models truncate and improvise more; grammar-constrained decoding fixes syntax but not meaning.
- Fixing Google Gemini API JSON Output Errors: A Practical GuideGemini API returning malformed or truncated JSON? This guide covers every error pattern with fixes and defensive coding strategies.9 min read
- DeepSeek R1 Distilled Models: Fix JSON Output Failures (All 6 Variants)DeepSeek R1 distilled models (1.5B–70B) break JSON differently than the full 671B model. Here's every failure mode and how to fix structured output reliably across all distilled variants.8 min read
- Local LLM JSON Output Debugging: Fix Ollama, vLLM, and llama.cpp Structured Output ErrorsSelf-hosted LLMs (Ollama, vLLM, llama.cpp, LM Studio) break JSON differently than cloud APIs. Here's how to debug every failure mode and get reliable structured output from your local inference stack.9 min read
- On-Device LLMs and JSON Output: Structured Output Reliability at 14MB (Needle2)Needle2 is a 14MB agentic LLM built for phones and wearables. But when tiny on-device models call tools and return JSON, how reliable is that structured output? Here's what breaks, why, and how to fix it.10 min read
- Cactus Needle 3 and JSON Reliability: Can 8-29MB Automation Models Produce Structured Output?Cactus Needle 3 is a 8-29MB automation LLM that uses byte-level grammar to guarantee valid JSON. But structural validity isn't the same as correct values. Here's what still breaks in tiny automation models and how to build a reliable repair pipeline.9 min read
- Jev by TypeSafe AI Promises 0% JSON Errors — What That Actually Means for Your PipelineTypeSafe AI's Jev model claims a 0% structured output error rate and 200x faster inference. We break down what it actually delivers, where it falls short, and why most JSON pipelines still need a repair layer.8 min read
MCP — Model Context Protocol
MCP errors are JSON-RPC 2.0 errors plus schema validation on inputSchema and outputSchema, now on draft 2020-12.
- MCP JSON-RPC Errors: Complete Fix Guide (2026)Getting JSON-RPC errors in your MCP server or client? This guide covers every MCP error code, what causes them, and how to fix them — with working code examples.10 min read
- MCP JSON-RPC 2.0 Errors: Complete Debug Guide for Model Context Protocol (2026)MCP uses JSON-RPC 2.0 as its wire format. Here's every error code, what triggers it, how the MCP spec extends it, and how to fix malformed JSON-RPC payloads from Claude, tool servers, and host apps.13 min read
- MCP JSON Schema Validation Errors: Complete Fix Guide (2026)MCP server tool schemas fail with invalid $ref, $dynamicRef, anyOf, and missing items errors. This guide explains every MCP JSON schema validation error and how to fix each one.10 min read
- MCP outputSchema Validation Failures: Why Structured Output Breaks and How to Fix It (2026)MCP outputSchema validation errors are breaking tools across IBM ContextForge, WooCommerce, edgartools, mastra-ai, and more. Learn the 5 failure patterns and exact fixes for 2026.11 min read
- MCP Tool Schema Validation Errors: Fix oneOf/anyOf/allOf Rejections (Provider Matrix)MCP tool schemas using oneOf, anyOf, or allOf are being rejected by Azure, Gemini, Kimi-Code, and Backstage right now. Here's the provider rejection matrix and exact fixes.16 min read
- MCP 2026 Spec: JSON Schema 2020-12 Migration Guide for TypeScript DevelopersThe MCP 2026 RC introduces two breaking JSON changes: JSON Schema upgraded to draft 2020-12 and error code -32002 changed to -32602. Fix your MCP server before the July 28 cutover.9 min read
- MCP July 28 RC Checklist: 6 JSON Changes Every Developer Must HandleMCP Release Candidate drops July 28, 2026. Six changes break JSON: outputSchema now enforced, inputSchema upgraded to JSON Schema 2020-12, error code -32002 remapped to -32602, and sessions removed. Complete developer checklist inside.11 min read
- MCP Python SDK v2 Beta: 5 JSON Breaking Changes Before June 30MCP Python SDK v2.0.0a1 is live, beta drops June 30. Five breaking changes affect how JSON flows through your MCP server: outputSchema validation, JSON Schema 2020-12, stateless sessions, error code remapping, and structuredContent flexibility. Full Python migration guide with code.11 min read
- MCP TypeScript SDK v2: Fix zod-to-json-schema Errors After the 2026-07-28 Breaking MigrationMCP TypeScript SDK v2 breaks zod-to-json-schema in three ways: transforms lost, draft-07 vs 2020-12 mismatch, and Zod 4.0–4.1 .describe() fallback drops descriptions. Step-by-step fix guide with TypeScript code.11 min read
- JSON Schema 2020-12 Migration Guide: MCP, Tool Schemas, and Breaking ChangesJSON Schema 2020-12 is now the default dialect for MCP tool inputSchema and outputSchema (SEP-2106, merged Jul 2026). This guide covers what breaks, new features, and how to migrate existing tool definitions.7 min read
Structured output and schemas
Schema-valid JSON can still be wrong; validate the shape with a schema and the values with an inspection step.
- LLM JSON Repair Guide: Fix Broken AI Output Online (2026)LLMs break JSON with markdown fences, Python booleans, truncated output, and smart quotes. This guide shows how to repair any LLM JSON error online or in code.10 min read
- LLM Structured Output Failures: When JSON Mode Breaks and How to Repair It (2026)Structured output mode doesn't guarantee valid JSON. Learn every provider-specific failure pattern for OpenAI, Claude, Gemini, and Mistral — and the exact repair patterns to handle them in production.14 min read
- LLM Structured Output Validation: Why Schema-Valid JSON Can Still Be Wrong (2026)Your LLM returns schema-valid JSON — but the values are wrong. Learn the Inspection Layer pattern: how to validate structured output beyond JSON Schema with Pydantic, Zod, and custom business logic checks.9 min read
- LLM JSON Schema Compatibility: Which Features Work in OpenAI, Anthropic, and Google (2026)Each LLM provider honors a different subset of JSON Schema. These gaps silently break production pipelines. Here's what actually works in OpenAI, Anthropic Claude, and Google Gemini.9 min read
- Cross-Provider JSON Schema Compatibility: Anthropic vs OpenAI vs Gemini (2026)Anthropic, OpenAI, and Gemini each honor a different subset of JSON Schema. The same Zod schema can be valid on one provider and silently rejected on another. Here's the full compatibility matrix and how to write portable schemas.12 min read
- 8 LLM Structured Output Libraries Ranked (2026): Instructor, BAML, XGrammar & MoreComparing the best libraries for getting reliable JSON from LLMs in 2026 — Instructor, BAML, XGrammar, Vercel AI SDK, PydanticAI, Outlines, Marvin, and Mirascope. Which one should your team use?13 min read
- Pydantic v3 JSON Output Guide: Structured LLM Responses in 2026Pydantic v3 is 10-30x faster than v2 with native streaming support for LLM structured output. Learn how to use Pydantic v3 models, allow_partial streaming, and fix common validation errors.8 min read
- JSON Schema for AI Agents: Production Validation Guide (2026)AI agents generate JSON at every step: tool calls, observations, memory, and final output. Learn how to validate agent JSON with JSON Schema in production LangGraph, CrewAI, and PydanticAI pipelines.9 min read
Agents and pipelines
Multi-step agents compound small JSON faults; repair at every tool boundary, not only at the end.
- JSON Output in AI Agent Pipelines: Why It Breaks and How to Fix ItMulti-agent systems live and die on valid JSON. Discover the five failure modes that break agent tool calls, how grammar-constrained decoding helps, and what repair-then-validate pattern production teams use in 2026.9 min read
- Why Computer-Use Agents Break JSON: Multi-Step Agent JSON Error Handling (2026)Computer-use and multi-step LLM agents break JSON in 5 predictable ways. Learn how schema rot, token truncation, and tool argument drift corrupt agentic pipelines — and how to fix them with validation, constrained decoding, and JSON repair.12 min read
- Computer Use Models and JSON: When GUI Automation Agents Produce Malformed Action SchemasCUA-S1 and other computer-use models emit JSON-encoded click, scroll, and type actions to drive GUI automation. Here's why those schemas break, how pipelines recover, and what repair tooling you actually need.12 min read
- LangChain JSON Output Parser: Fix Parsing Errors and Ensure Valid OutputLangChain returning OutputParserException or \"invalid json output: none\"? Fix it in minutes — exact code for Python literals, markdown fences, streaming failures, and fallback parsers.9 min read
- StemJSON and the Rise of JSON as an LLM Instruction LanguageStemJSON lets LLMs generate native mobile app features on the fly using a JSON-based DSL. Here's how it works, where JSON-as-instruction breaks down, and why a repair layer stays relevant.12 min read
Still dealing with broken JSON?
Paste it in and get it fixed in under 1 second — free, no signup, no install. Works with ChatGPT, Claude, n8n, and any AI output.
Fix My JSON Free →Every guide here is written from reproduced cases by the maintainer of the repair engine — about the site.