Code block extractor
LLMs love to wrap code in markdown fences and surround it with explanation. When you just want the code — maybe several files across several languages in one reply — copying it by hand is tedious and error-prone. This tool reads the whole response, pulls out every fenced code block, labels each by language, and lets you copy any one of them, or all of them at once.
How it works
The extractor scans for standard markdown fences: an opening line of three or
more backticks with an optional language tag, the code body, and a matching
closing fence. It captures each body verbatim and records the language from the
opening line — python, ts, bash, and so on — defaulting to “text” when no
tag is present. Blocks are returned in document order, each shown with its
language label and an individual copy button, plus a copy-all action that joins
them for a quick paste into your editor.
When to use this tool
The most common scenario is a “generate a full project scaffold” prompt. A single
ChatGPT or Claude reply can include a package.json, a TypeScript file, a
Dockerfile, and a shell install script — all wrapped in separate fences. Rather
than scrolling through the prose and manually selecting each block, paste the
entire response here and grab every file in seconds.
Other useful cases:
- Code review replies — models often return the fixed code alongside commentary; extract just the corrected file.
- SQL generation — pull the query block away from the explanation text before running it in a client.
- Multi-step tutorials — extract every command block into one list so you can run them in order without re-reading the tutorial.
Worked example
Suppose you paste a model response that contains two TypeScript snippets separated by explanation: one for a greet function and one for its test. The tool finds both fenced blocks, labels each as ts, and gives each its own copy button. The copy-all action concatenates them so you can paste both into your editor at once — two files in one paste, no manual hunting through prose.
Notes and tips
- Language labels come from the fence. Whatever tag the model wrote after the opening backticks is what you see — accurate as long as the model tagged it.
- Untagged blocks become “text”. Plain triple-backtick blocks still extract; they are just labeled generically.
- Flat fences work best. Top-level fences — the format virtually every LLM uses — extract cleanly; rare nested fences may not split perfectly.
- No stripping prose. The tool preserves each block verbatim, including leading or trailing blank lines inside the fence, so indentation in YAML/Python/etc. is kept intact.
- Stays in your browser. Nothing leaves the page, so paste proprietary code without concern.