Extract JSON from Markdown
Paste any LLM response or markdown text and extract every JSON block — fenced or inline.
Related Tools
What Does This Tool Do?
When you ask an LLM to return JSON, the response is almost never raw JSON — it's JSON wrapped in markdown: a prose introduction, then a ```json code block, then an explanation. Sometimes the model puts multiple JSON objects in a single response. Sometimes it embeds a small JSON snippet inline in the prose without a code fence.
This tool extracts every JSON block from any markdown or prose text — fenced blocks (tagged ```json or untagged ```), inline JSON objects and arrays embedded in sentences, and broken JSON that needs a repair pass first. When multiple blocks are found, you can select each one individually or merge them all into an array.
How to Use This Tool
- Paste the full LLM response (or any text containing JSON) into the Input panel.
- All JSON blocks found are listed on the right — click one to select it.
- Use Merge all into array to combine multiple blocks into a single JSON array.
- Copy or download the extracted JSON with the action buttons.
What Gets Extracted
Fenced (tagged)
```json\n{...}\n```
Most common — explicitly tagged JSON code blocks.
Fenced (untagged)
```\n{...}\n```
Untagged code blocks where the content is valid JSON.
Inline JSON
...response was {...} which...
JSON objects or arrays embedded directly in prose text.
Frequently Asked Questions
- What types of JSON does this tool extract?
- It finds JSON in three ways: (1) fenced code blocks tagged with ```json or ```JSON, (2) untagged fenced code blocks (``` ```) where the content is valid JSON, and (3) inline JSON objects or arrays embedded directly in prose text. All three patterns appear regularly in LLM responses.
- What if the extracted JSON has trailing commas or single quotes?
- The extractor automatically attempts to repair common JSON errors using jsonrepair before presenting a block. So if your LLM wrote {"key": 'value',} in a code block, you'll still get clean JSON in the output. The repair is transparent — you just get valid JSON.
- What does 'Merge all into array' do?
- When multiple JSON blocks are found, you can combine them into a single JSON array where each element is one of the extracted blocks. This is useful when an LLM splits a response across multiple code blocks and you want to process them together.
- Why would an LLM put JSON outside a code block?
- LLMs sometimes embed JSON inline in prose: 'The response was {"status": "ok"} which means...' — especially for short objects, or when the model didn't follow instructions to use a code fence. The inline extractor catches these by scanning for balanced { } and [ ] patterns in the text.
- How do I tell the LLM to always use code fences?
- Add this to your system prompt: 'Always wrap JSON responses in a ```json code block. Return only the JSON object, no explanation before or after the code block.' For OpenAI, you can also use response_format: { type: "json_object" } which forces raw JSON output with no markdown.
- Can I extract JSON from a full API response body?
- Yes — paste any text, not just AI responses. The tool works on documentation snippets, Stack Overflow answers, API docs, GitHub comments, or any prose that embeds JSON. It finds all valid JSON blocks regardless of the surrounding content.
- What if no JSON is found?
- The tool shows a 'No JSON found' state with suggestions. The most common reasons are: the text only contains prose with no JSON, the JSON is too deeply mangled to repair, or the content is in a non-JSON code block (```typescript, ```python etc.) — those are intentionally excluded.
- Does this work with JSONL (newline-delimited JSON)?
- Partially. Each line of a JSONL block is a separate valid JSON value, so the tool will extract the entire block content as a single unit and attempt to parse it — which fails for multi-line JSONL. Use the JSONL Viewer tool for proper JSONL handling.
About This Tool
Extract JSON from Markdown is one of JSON Kit's AI-era differentiators — it exists because the problem of LLMs wrapping everything in markdown is universal, and no mainstream JSON tool addressed it before. The extractor handles fenced blocks, inline JSON, and broken JSON (via automatic jsonrepair). It finds all blocks in a single pass, shows them with source context, and lets you merge multiple blocks into an array. 100% browser-side — your LLM responses never leave your device.