Converter tool

Code Folder to Prompt File

Turn a project folder into one Markdown or XML-style file you can paste into an AI chat: a folder tree, then each source file in a labelled block. Dependency folders, lock files, binaries and .gitignore matches are left out, and the folder is read on your device.

Choose a project folder, or drag the folder onto this box

Up to 5,000 files and 50 MB of text after the ignore rules.

Your browser may ask you to confirm before it shows a folder to this page, and the prompt can use the word upload. The files are only read by this tab; this tool sends none of their contents anywhere.

What to leave out
Output format

Preview

Output Preview

Choose a folder to list its files here with sizes and estimated tokens, then copy or download the prompt file.

Code Folder to Prompt File

Operator: Abdulla Al Fahad. How tools are built and checked

Asking an AI chat about a codebase usually starts with copying files into the message one by one, losing track of which ones already went in, and at some point pasting a lock file that is longer than the code itself. This tool takes the whole project folder instead and writes a single text file: a tree of the folder at the top, then each source file under a heading with its path, inside a code fence labelled with its language. Dependency folders, build output, lock files, images and anything your root .gitignore excludes are dropped before any of their files are opened.

Each remaining file is listed with a checkbox, its size and an estimated token count, so a bulky test fixture or a generated API client can be left out before you copy anything. The figure above the list is an estimate for the finished prompt file, with the tree, headings and fences counted, which makes it easy to compare with the context limit published for the model you plan to use.

Key features

  • Folder picker, folder drag and drop, or individual files
  • Skips node_modules, dist, build, .next, coverage, vendor, __pycache__ and .venv at any depth (switchable); .git is always skipped
  • Skips package-lock.json, pnpm-lock.yaml, yarn.lock and other dependency lock files (switchable)
  • Applies simple patterns from the root .gitignore and lists the lines it could not apply
  • Extra ignore patterns typed on the page, in the same syntax
  • Binary files skipped by extension, or by a NUL byte in their first 8 KB
  • .env files and private-key names listed but left unticked
  • Checkbox tree with per-file size and estimated tokens, folder ticks and tick all or none
  • Markdown or XML-style output, copied to the clipboard or saved as .md or .txt

What the Markdown and XML-style files look like

Input is a folder chosen with Choose folder, a folder dragged onto the box, or a handful of files picked one by one with Pick files instead. Paths in the output are relative to the folder you chose, so src/parse.ts rather than a full path from your disk. Most source files are UTF-8 and are read that way. A UTF-16 byte-order mark at the top switches the decoder to UTF-16, and a file whose bytes break the UTF-8 rules is decoded as Windows-1252 instead and tagged in the list, so you can look over its accented letters before sending it.

The Markdown layout starts with "# folder-name" and the tree in a text fence. Every ticked file then gets a "## path" heading and a fenced block whose language tag comes from the extension or a known file name: ts for .ts, python for .py, go, rust, json, yaml, dockerfile for a Dockerfile and so on. An unknown extension gets a fence with no tag. The fence is three backticks, or one more than the longest run of backticks inside the file, so a README full of ``` examples gets a four-backtick fence and cannot close its own block early. Line endings are written as LF, and one trailing newline per file is folded into the closing fence.

The XML-style layout wraps everything in <folder name="...">, puts the tree in a <tree> element and each file in <file path="...">. Only the path attribute is escaped. The file text goes between the tags exactly as written, which keeps code readable but means the result is a prompt layout rather than a valid XML document. If a file itself contains the text </file>, the page names it and suggests the Markdown layout instead.

One run lists up to 5,000 files and reads up to 50 MB of text, both counted after the ignore rules. Files over 1 MB each are skipped unread by default; the limit can be set to 100 KB, 250 KB, 500 KB, 2 MB or 5 MB instead.

How it works

The root .gitignore is read first, if the chosen folder has one and it is under 1 MB. Each path is then tested against the rules in a fixed order: .git, the dependency and build folders, the lock file names, the .gitignore lines, then your extra patterns. The first rule that matches decides, and the list of left-out items shows which rule that was. A file inside an ignored folder is never opened.

How much the browser does before the rules apply depends on how the folder arrives. A dragged folder is walked one entry at a time, and a folder that matches a rule is not even opened, so the files inside a large node_modules are never listed. With the Choose folder button the browser assembles the full file list first, dependency folders included, and the page then discards ignored paths by name without reading them. On a project with a big dependency tree, dragging is the lighter route.

Files that survive the rules are sorted into tree order: inside every folder, subfolders first, then files, alphabetically without regard to case. A name with a binary extension (images, fonts, archives, PDFs, Office files, compiled objects, databases, model weights) is skipped without being read, and so is anything above the size limit. Every other file is read: if its first 8 KB contain a NUL byte it is marked as binary content and dropped from the output; otherwise its text is decoded and its tokens are estimated with the method printed under the total.

Ticking, unticking or switching layout rebuilds the output from text already in memory. Changing a skip option, the size limit or a pattern lists the folder again with the new rules, and reuses the text of any file that was read before.

Common use cases

  • Giving an AI chat a small library in full before asking why one test fails
  • Asking for a review of one feature folder, such as src/billing, without the rest of the app
  • Sending a model the code plus the README so it can draft documentation that matches the real function names
  • Checking how many tokens a service would take up before deciding whether to send all of it or one module
  • Keeping a snapshot of a prototype's source as one readable text file

How to use this tool

  1. Press Choose folder and pick the project's top folder, or drag the folder from your file manager onto the box. Your browser may ask you to confirm first.
  2. Leave the skip options on unless you need something they hide, such as a vendored library you changed by hand.
  3. Read the notes above the list: how many .gitignore patterns were applied, which lines were not, and which files were left unticked because their names suggest secrets.
  4. Untick folders and files the question does not need. Generated code, snapshots and large fixtures are the usual candidates; the Est. tokens column shows where the bulk is.
  5. Choose Markdown or XML-style tags, check the start of the prompt file in the preview, then press Copy prompt file or download it.

Example

tip-calc, dragged onto the page (10 files)

tip-calc/
  .env                             API_TOKEN=replace-me
  .gitignore                       dist/, *.log, !keep.log
  README.md                        53 bytes, contains a ```sh block
  package.json                     47 bytes
  package-lock.json
  assets/icon.png
  dist/cli.js
  logs/run.log
  node_modules/minimist/index.js
  src/tip.ts                       106 bytes

tip-calc-prompt.md, complete: 4 files, 454 characters, about 97 tokens (68 to 131)

# tip-calc

```text
tip-calc/
├── src/
│   └── tip.ts
├── .gitignore
├── package.json
└── README.md
```

## src/tip.ts

```ts
export function tip(bill: number, percent: number): number {
  return Math.round(bill * percent) / 100;
}
```

## .gitignore

```gitignore
dist/
*.log
!keep.log
```

## package.json

```json
{
  "name": "tip-calc",
  "version": "1.0.0"
}
```

## README.md

````markdown
# tip-calc

Usage:

```sh
node dist/cli.js 42 15
```
````

Tips for best results

  • Choose the narrowest folder that answers the question. src/billing with the shared types is usually a better prompt than the whole repository.
  • Sort out the big files first: the Est. tokens column shows them, and one generated client can outweigh all the hand-written code.
  • Keep package.json or its equivalent ticked. It tells the model which framework and versions it is looking at, for very few tokens.
  • Use Extra ignore patterns for project-specific noise such as __snapshots__/, *.min.js or fixtures/, rather than unticking the same files after every load.
  • If the project has its own .gitignore in a subfolder, copy its useful lines into Extra ignore patterns with the subfolder path in front, since only the root .gitignore is read.

Edge cases to watch

Only simple .gitignore patterns are applied: plain names, * and ? inside one name, a trailing slash for folders, a leading slash or a slash in the middle to anchor a path to the root. Lines that start with ! (negation), use ** or [ ] classes, or contain a backslash are not applied, and the page lists them. A negation line is the one to watch: "*.log" with "!keep.log" still leaves keep.log out here, where Git would include it.

Only the .gitignore at the top of the chosen folder is used. Nested .gitignore files, .git/info/exclude and your global Git ignore file are not read, so files they hide in Git can still appear in the list.

Pattern matching is case-sensitive, the way Git behaves on Linux. A rule for Build/ does not hide a folder called build; on macOS and Windows, where Git usually ignores case, the two can behave differently.

The secret check looks at file names only. An API key pasted into config.ts or a test fixture is not detected, so read what you send. Anything you paste into a chat leaves your device under that service's terms.

Binary detection reads the first 8 KB. A file that is text at the start but binary further in, such as some data dumps, can get through as garbled text; untick it if the size or token count looks wrong for what it is.

Common errors and how to fix them

"More than 5,000 files are left after the ignore rules."
The folder is too broad for one prompt. Choose a subfolder such as src, or add the folders you do not need (for example assets/ or generated/) under Extra ignore patterns and the list is rebuilt.
"The text files left after the ignore rules add up to ... over the 50 MB this tool reads in one go."
Lower the per-file size limit so large data files are skipped unread, add patterns for data or fixture folders, or choose a smaller folder.
"Every file in this folder matched an ignore rule, so nothing is left to pack."
You probably chose a folder such as dist or build, which the dependency and build rule hides entirely. Choose the source folder, or untick Skip dependency and build folders if you really want that output.
The folder loads but a file you expected is missing from the list.
Open "Left out by ignore rules" above the list. It names the rule behind each skipped folder or file, such as ".gitignore: *.log" or "your pattern: fixtures/".
Copy prompt file says the copy was blocked.
A browser may refuse to place very large text on the clipboard, or block clipboard access on the page. Use the download button and open the saved file instead.

Best practices

  • Write the question first, then add the code it needs, rather than packing everything and hoping the model finds the relevant part.
  • Put your instructions before or after the prompt file, not inside it, so they are not mistaken for one of the source files.
  • Re-check the ticks after changing a skip option: files that come back into the list are ticked by default unless their names suggest secrets.
  • Compare the token estimate with the model's published limit and leave room for the reply, which counts towards the same window.

What happened to each file in the example

Ten files went in and four came out. package-lock.json matched the lock file rule. node_modules/minimist/index.js was covered by the dependency folder rule, and dist/cli.js by the build folder rule, which is checked before the .gitignore line that also names dist/. logs/run.log matched the .gitignore pattern *.log, and the line !keep.log was reported as not applied. assets/icon.png was skipped as a binary type without being read, and .env was listed but left unticked because its name suggests credentials, so the summary reads 4 of 5 text files.

The four files in the prompt hold 228 bytes of plain ASCII, so 228 characters. The prompt file is 454 characters, line breaks included, because the tree, the headings and the fence lines are counted too; that whole text is what the token estimate of 97 (68 to 131) describes. The README contains a ```sh block, so its own fence has four backticks and the inner block survives intact.

Choosing between Markdown and XML-style tags

Both layouts mark where one file ends and the next begins; no model requires either one. Markdown is easier to read yourself and renders cleanly if you paste it into a document or an issue. Its fences are sized to each file, so a file's contents can never break the structure.

XML-style tags put the path in an attribute and keep the file text completely bare, with no fence lines. Some people prefer them when a prompt already uses tags for instructions and examples. Keep in mind that the text is not escaped, so this is only safe as long as no file contains the closing tag itself, which the page checks for you.

Where the folder goes

Your browser lets the page read the files you chose, inside this tab. The text of each file it reads goes into a cache in the tab's memory, keyed by path, so unticking a file, switching layout or changing a skip option reuses text already read instead of opening the file again. Choosing another folder replaces that cache with an empty one, and closing or reloading the tab discards it. This tool transmits no file names or contents; they leave your device only when you paste or upload the prompt file yourself.

The download is ordinary UTF-8 text with an .md or .txt name, and nothing in it is shaped for one particular chat service. Attachment types, upload sizes and message length caps belong to each service and shift over time, so check them with the service you plan to use. Pasting the text into the message box avoids the attachment question altogether, though a very long paste can still run into a length cap.

Frequently asked questions

Are comments or blank lines removed to save tokens?

No. File text is copied as written apart from line endings, which become LF. Comments often explain why code looks the way it does, which is useful to a model; untick files rather than trimming them if you need a smaller prompt.

Why is the total not the sum of the Est. tokens column?

The two measure different text. Each row estimates one file's contents, while the total is worked out on the finished prompt file, which also holds the tree, the # and ## headings and every fence line. In the tip-calc example the four rows read 23, 5, 11 and 13, which add up to 52, yet the prompt file comes to about 97. Both figures come from character and word counts, so use them to judge whether a folder fits a model's limit, not as exact counts.

Why does Choose folder take longer than dragging on a big project?

With the picker, the browser itself collects every file in the folder, including everything inside node_modules, before the page sees the list. A dragged folder is walked by the page, which can skip ignored folders without opening them.

Does it follow symbolic links?

That depends on the browser's file access, not on this tool. To protect against loops, folders nested more than 40 levels deep are not opened and are listed among the left-out items.

Can I use it on a phone?

Many phone browsers do not offer a folder picker. Pick files instead lets you choose several files at once; they are placed at the top level of the tree under the name selected-files.