All tools

Extract JSON

AI / Agent

Pull JSON blocks out of mixed LLM output: handles markdown code blocks and inline JSON objects/arrays.

An LLM chat completion rarely returns just the JSON you asked for: it wraps it in a markdown fence, adds explanatory text before or after, or returns several objects mixed with commentary, and this scans for all of it and pulls out just the valid JSON blocks. It's pattern matching and JSON parsing, not a repair step. If the model produced technically invalid JSON (a trailing comma, say), pipe the extracted text into JSON Repair afterward rather than expecting this tool to fix syntax errors itself. Multiple JSON blocks in one response are all captured, so it's worth checking that the specific block you wanted was the one you got if a response contains several. The same extraction logic is available via the REST API and SDKs for parsing LLM output at scale rather than one response at a time.

jsonextractllmoutputparsecode-block

How to use Extract JSON

  • 1.Paste raw LLM output that contains a JSON object wrapped in a markdown code fence to pull out just the valid JSON.
  • 2.Use it on messy chat completions where the model added explanatory text before or after the JSON you actually want.
  • 3.Extract multiple JSON blocks from a single response when an LLM returns several objects or an array mixed with commentary.

Frequently asked questions

Does this run in my browser or on a server?
Extraction runs entirely client-side using pattern matching and JSON parsing — your text isn't sent anywhere.
What if the LLM output has malformed JSON, like a trailing comma?
This tool extracts candidate JSON blocks but doesn't repair syntax errors — pipe the extracted text into a JSON Repair tool if the LLM produced technically invalid JSON.
Does it handle nested code fences or multiple JSON blocks?
Yes, it scans for all markdown code blocks and inline JSON-like structures and returns each one it finds, so check that it captured the specific block you wanted if there are several.
Can I use this in an automated pipeline?
Yes — the same extraction logic is available via the REST API and SDKs, which is the more practical route if you're parsing LLM output programmatically at scale.

Use via API, SDK, or MCP

cURL# Free: 1,000 req/day · Pro: 10,000 req/day
curl -X POST https://api.utilix.tech/v1/tools/extract-json \
  -H "Authorization: Bearer utx_live_..." \
  -H "Content-Type: application/json" \
  -d '{"text":"Here is the result: {\"status\":\"ok\",\"count\":42} and some more text."}'

Get an API key from your dashboard · Full API docs →