A simple CLI tool that exports a project's relevant text files into a single, structured file.
export-codebase is useful when you want to share a codebase, archive a project, or provide an entire project as context to an LLM.
- Respects your project's
.gitignore - Automatically excludes
node_modules,.git, build outputs, lock files, and environment files - Keeps
.env.examplewhile excluding other.envfiles - Skips binary files
- Skips files larger than 1 MB
- Generates an ASCII project structure
- Preserves each file's relative path in the output
- Supports custom output filenames
- Supports hidden files when explicitly enabled
- Works with any project, regardless of programming language
You don't need to install it globally.
Run it directly with npx:
npx export-codebaseOr install it as a dependency:
npm install export-codebaseRun the command from the root of your project:
npx export-codebaseBy default, it creates:
project.txt
The generated file contains the project structure followed by the contents of the relevant files.
Example:
// Project structure
my-project/
├── src/
│ ├── index.ts
│ └── utils.ts
├── package.json
└── README.md
// src/index.ts
import { hello } from "./utils.ts"
hello()
// src/utils.ts
export function hello() {
console.log("Hello, world!")
}
This makes it easy to copy an entire project into an LLM or share it as a single file.
Use -o or --output to specify the output filename:
npx export-codebase -o codebase.txtUse -s or --silent to suppress informational logs:
npx export-codebase --silentWarnings, errors, and the final summary are still displayed.
Include hidden files
Hidden files and directories are excluded by default.
Use --include-hidden to process hidden files that are not otherwise ignored:
npx export-codebase --include-hiddenexport-codebase automatically excludes:
- Files and directories matched by
.gitignore node_modules.git.envand other environment files- Build outputs such as
dist,build,out,coverage, andtarget - Package manager lock files
- Binary files
- Files larger than 1 MB
- The generated output file itself
.env.example is intentionally not excluded.
When working with AI coding tools, you often need to provide context from an entire codebase.
Copying files manually is tedious, while sending an entire directory can include unnecessary files such as dependencies, build artifacts, binaries, and secrets.
export-codebase creates a clean, structured representation of your project in a single file.
Project
↓
export-codebase
↓
project.txt
↓
LLM / sharing / archiving
- Node.js 18 or newer
Clone the repository and install dependencies:
git clone https://github.com/brkunver/export-codebase.git
cd export-codebase
npm installBuild the project:
npm run buildRun the CLI:
npm startRun the manual smoke test:
npm run fulltestThis project is licensed under the GNU General Public License v3.0.
See the LICENSE file for details.