Markdown Extractor (FeiMao-326)
Strip the ```json fences out of LLM replies before your parser chokes on them
- text
You asked an LLM for JSON and it gave you this: "Sure! Here is your JSON:\njson\n{\"subject\": \"...\"}\n". If you feed that straight into a JSON parser, it crashes on the markdown fences and the "Sure!" preamble. This node exists for exactly one reason: to peel the conversational wrapper off LLM output and hand you the clean code-block content.
How it works
Three inputs: text (the raw LLM reply), plus two toggles. The node regex-searches for fenced code blocks - anything wrapped in triple backticks, with or without a language hint like json. Then:
first_block_only(default on) returns just the first code block, trimmed. With it off, all blocks come back joined by blank lines. For most workflows - you asked for one JSON object - first-only is the right call.remove_artifacts(default on) scrubs lingering markdown signs: bold**...**,__...__, and leading#heading markers. That's the "the model put markdown inside the block too" insurance policy.
Two output behaviors that matter:
- No code block found? You get the original text back, unchanged. This is the smart part - it means you can drop this node in front of anything and it degrades gracefully when the model does behave and skips the fences.
- The output is a single
textstring. From there you'd normally wire it into the pack's JSON Parser (or whatever parser you're using).
Where it fits
This node is the middle link in the pack's recommended pipeline:
General API Node (force_json_format ✅) → Markdown Extractor → JSON Parser
The idea: you've asked the model for structured output, and even with force_json_format on, models are chatty - they'll happily wrap your JSON in fences and a "Here you go!" because that's how they're trained. This node strips all of that so the parser sees pure JSON.
It's genuinely useful beyond this pack too. Any time an LLM output arrives in your graph wrapped in markdown - prose, tables, code - this extracts the fenced content so you can do something with it. If you've ever pasted model output into a node and watched it fail on invisible backticks, you know the pain it removes.
The main limitation is scope: it extracts code blocks, not arbitrary text between other markers. If your model wraps answers in HTML or some custom format, this isn't the tool - Regex Extractor Pro (same pack) is.
Inputs and outputs
text(STRING, multiline) - the raw LLM reply.remove_artifacts(BOOLEAN) - strip residual markdown formatting.first_block_only(BOOLEAN) - first block, or all blocks joined.text(STRING) - the extracted content.
Installing
It's one of the sixteen nodes in the FeiMao-326 pack. ComfyUI Manager (search "Comfyui-General-API-Node") or:
cd ComfyUI/custom_nodes
git clone https://github.com/FeiMao-326/Comfyui-General-API-Node.git
cd Comfyui-General-API-Node
pip install -r requirements.txt
Restart ComfyUI. The pack's dependencies are light (openai, numpy, Pillow, requests) and there are no model files to download.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| remove_artifacts | BOOLEAN | true | — |
| first_block_only | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |