Zero-dependency CLI + library that pulls structured output out of messy LLM / markdown text:
files— parse fenced```code blocks and write them to real files, inferring the filename from hints:`**app.js**`,```js title="app.js",```app.js, a leading// app.jscomment, or`src/path.ext`on the line before the block.json— find and print the first JSON value embedded in prose or a```jsonfence (balanced-brace scan + trailing-comma repair).
No API key, no network, no dependencies — just Node 18+.
npx llm-extract --help
# or, from a clone:
node bin/llm-extract.js --help# Materialize an LLM's multi-file answer into ./generated
pbpaste | llm-extract files --out ./generated
# Pull the JSON out of a chatty response
cat reply.md | llm-extract jsonfiles writes every block that has a detectable filename (others are skipped
with a note) and refuses paths that escape the output directory.
import { parseBlocks, extractJson } from 'llm-extract';
parseBlocks('**a.js**\n```js\nx\n```');
// [{ lang: 'js', code: 'x', filename: 'a.js' }]
extractJson('Sure! {"a": 1, "b": [1, 2,] }');
// { a: 1, b: [1, 2] }npm test # node --testMIT
If this project is useful to you, you can support its development with a crypto tip — thank you!
USDT — Ethereum (ERC-20):
0xad39bdf2df0b8dd6991150fcea0a156150ed19b8
Send only on the Ethereum (ERC-20) network.