Extract Files and Folder Structures from AI Answers Instantly
Modern Large Language Models (LLMs) like ChatGPT (GPT-4o), Anthropic Claude 3.5 Sonnet, DeepSeek-V3, and Google Gemini excel at generating full project code bases. However, working with multi-file answers is tedious: developers are forced to manually create nested folders, create empty files, scroll through long responses, and copy-paste each markdown code snippet individually.
AI Reply to Files is a dedicated developer utility designed to eliminate that friction. By pasting the complete AI markdown conversation into this browser-based tool, you can automatically parse, sanitize, preview, and download all code blocks as a structured ZIP file with clean directory hierarchies—in under a second.
How to Use: 5 Simple Steps
- Copy the full AI reply: Highlight or click "Copy" on your ChatGPT, Claude, or DeepSeek conversation output.
- Paste into the left editor: Insert the markdown into the workspace. The tool parses code fences automatically with a 250ms debounce.
- Review detected files and paths: Inspect the hierarchical file tree in the right pane. File paths and languages are recognized automatically.
- Adjust filenames or code: Click any file in the tree to edit its relative folder path, programming language, or inline source code.
- Download your ZIP: Click Download ZIP to produce an archive matching your project's exact folder structure.
Before and After Comparison
Here is the implementation:
### src/services/auth.ts
```typescript
export function login(user: string) {
return { token: "secret_jwt" };
}
```
Next, in `components/UserProfile.tsx`:
```tsx
export const Profile = () => <div>Hello</div>;
```
project.zip
├── src/
│ └── services/
│ └── auth.ts
├── components/
│ └── UserProfile.tsx
└── REPLY.md (optional backup)
How the File Path Parser Works
Different AI models and prompting styles present file names in varied ways. To achieve optimal extraction accuracy, our deterministic parser tests each code block against four descending tiers:
- Tier 1 — Info-string attributes: Code block fence declarations such as
```typescript title="src/utils/parser.ts"or```json filename=package.json. - Tier 2 — First-line comment heuristics: Comments placed inside the block by the model, such as
// app/router.go,# config/settings.py, or<!-- public/index.html -->. - Tier 3 — Surrounding markdown text: Headings and phrases immediately preceding the block, such as
### `src/server.js`,Save this as `docker-compose.yml`:, orIn components/Button.vue:. - Tier 4 — Intelligent extension fallback: If no explicit name is provided anywhere, the tool maps the language to an appropriate extension (e.g. Python to
snippet-1.py, TypeScript tosnippet-2.ts) using an internal dictionary of over 40 programming languages.
Built-In ZIP-Slip and Path Traversal Protection
When extracting files from arbitrary text, security is paramount. Malicious or hallucinated code blocks could potentially attempt path traversal attacks (such as ../../../../etc/passwd or Windows drive letters like C:\Windows\System32).
Our path sanitizer neutralizes these threats before building the archive:
- All backslashes (
\) are normalized to standard forward slashes (/). - Windows drive letters (e.g.
C:,D:) and absolute root slashes are stripped. - Directory traversal sequences (
..and.segments) are collapsed or removed. - Illegal system characters (
: * ? " < > |) are replaced with clean hyphens. - A visual warning tag is displayed whenever a filename required sanitization.
Common Problems & Edge Cases Handled
Real-world AI replies frequently contain syntax anomalies that cause standard parsers to fail:
- Unclosed Code Fences: When an AI hits token limits or response timeouts, the final code block may lack closing backticks. Our parser recognizes unclosed fences, preserves the code, and alerts you that the response was truncated.
- Nested Fences in Markdown Guides: When an AI writes a README containing another code block, outer fences use 4 backticks (
````) wrapping 3 backticks (```). Our parser respects CommonMark nesting rules. - Diff & Patch Blocks: Unified diffs (
```diff) are recognized, assigned a.diffextension, and flagged with a distinct purple badge so you know they are patches rather than complete files. - Repeated or Revised Files: When you ask an AI to fix a bug in a file it previously output, both versions appear in the conversation. By default, our duplicate resolver supersedes older versions while preserving the latest revision.
Frequently Asked Questions
How do I extract files from an AI reply?
How do I get the file paths from an AI answer?
How do I save multiple files from a ChatGPT answer?
How are file names detected?
Is the code run?
Is my reply uploaded?
Related Free Developer Tools by MafLabs
Discover more private, browser-based developer utilities designed to make web development and data processing effortless:
- JSON to TypeScript Interface Generator — Convert raw API JSON into clean, typed interfaces locally.
- Browser Regex Playground — Test regular expressions in real-time with visual grouping and zero server latency.
- Side-by-Side Diff Viewer — Compare text, code, and markdown files securely without third-party logging.