Extract valid JSON from LLM outputs, malformed data, and messy text.
Indestructible. Self-Repairing. Lightweight.
Paste any text containing JSON — messy, malformed, or buried in markdown. Watch loot-json extract it flawlessly.
Built for the real world where JSON is never perfect. Stop fighting with parsers and start shipping features.
Handles malformed JSON, missing quotes, trailing commas, and more. Your data survives the chaos.
Automatically fixes common JSON errors. Missing brackets? Unquoted keys? We've got you covered.
Zero dependencies. Under 5KB minified. Blazing fast extraction that won't bloat your bundle.
Specifically designed to extract JSON from LLM outputs — markdown code blocks, mixed text, you name it.
Full TypeScript support with generics. Get type-safe JSON extraction out of the box.
Simple API: just loot(). No configuration needed, works instantly.
import { loot } from 'loot-json';
// LLM response with embedded JSON
const llmOutput = `Here's your data:
{"name": "Alice", "score": 95}
Hope this helps!`;
// Extract the JSON effortlessly
const data = loot(llmOutput);
// → { name: 'Alice', score: 95 }