Export a local Git repository’s structure and source files into one text file. Useful for code reviews, quick sharing, archiving—or pasting into a tool to get a high-level overview of a codebase.
- Walks your repo and collects files by extension.
- Writes a Table of Contents (TOC) with relative paths, sizes, and modified times.
- Concatenates file contents in a deterministic order (sorted by path).
- Skips noisy stuff by default (
.git/
,node_modules/
,__pycache__/
, etc.). - Interactive picker (optional) to choose exactly which folders/files to include (Textual 5.x).
Why this instead of a zip? You get a single, readable text file with a compact TOC up top and all the content below—easy to skim, search, diff, or paste where plain text works best.
Python 3.9+ recommended.
From source:
git clone https://github.com/thenarfer/repo-to-txt.git
cd repo-to-txt
# Base CLI:
pip install -e .
# Add the interactive picker:
pip install -e .[interactive] --use-pep517
Basic export (current directory):
repo-to-txt
Explicit path and output:
repo-to-txt /path/to/repo -o all_code.txt
Filter by extension (repeat -e
as needed):
repo-to-txt . -o out.txt -e .py -e .md
Exclude directories (repeat --exclude-dir
):
repo-to-txt . -o out.txt --exclude-dir build --exclude-dir dist
Interactive picker:
repo-to-txt --interactive . -o out.txt
Show version:
repo-to-txt --version
The TUI lets you tailor the export without typing long filters. It’s built on Textual 5.x.
Keys
-
↑/↓
– move -
→
– expand directory -
←
– collapse directory -
Space
– toggle include- on a file: toggles just that file
- on a folder: toggles the entire subtree
-
*
– also toggles the entire subtree -
A
– select all -
N
– select none -
D
– re-apply smart defaults -
/
– filter by extensions (e.g.py,ts,md
) -
Enter
– export with current selection -
?
– toggle help -
Q
– quit without exporting
Notes • The picker avoids very large files and common binary/lock formats. • Checkboxes are simple
☑/☐
; if your terminal can’t render them, the state still works.
REPO EXPORTER OUTPUT
====================
TABLE OF CONTENTS
-----------------
src/app.py | 1024 bytes | modified 2025-08-18T10:30:00
src/utils/strings.py | 768 bytes | modified 2025-08-18T10:05:00
README.md | 512 bytes | modified 2025-08-18T10:00:00
FILE CONTENTS
-------------
--- File: src/app.py ---
# contents...
--- File: src/utils/strings.py ---
# contents...
--- File: README.md ---
# contents...
- Paths are relative and always use forward slashes.
- The TOC gives you a quick “map” before the full content.
If you prefer a tree-style glance before exporting, run the system tree
command in your repo (not part of this tool):
tree -a -I '.git|node_modules|__pycache__|dist|build|.venv|venv|env'
The export itself uses the TOC for structure.
If your goal is a “readable dump” for tools that only accept text:
- Use the picker to avoid binaries and trim noise.
- Start with
README.md
,py/js/ts
, config, and a few representative test files. - Large repos: split by top-level folders and run multiple exports (one file per area).
- The TOC at the top gives a compact overview; many tools can use that to navigate.
That’s it—no special integrations here; just a single, predictable text file.
- Included extensions (non-interactive): common source/text types (e.g.,
.py
,.js
,.ts
,.md
,.json
,.yml
,.xml
,.sh
, …). Use-e
to override. - Excluded directories:
.git
,node_modules
,__pycache__
,dist
,build
, venvs,.pytest_cache
,.vscode
, etc. - Excluded by pattern: lockfiles and common binaries/images (e.g.,
package-lock.json
,*.sqlite
, images, PDFs). - Size limits (picker): very large files are skipped by default.
- Selection wins: in interactive mode, the export uses precisely what you selected.
Install for hacking:
pip install -e .[interactive] --use-pep517
Run tests:
pytest
The suite covers CLI behavior, ordering, selection semantics, filtering, and core TUI logic.
- Picker won’t start: make sure you installed the extras:
pip install -e .[interactive] --use-pep517
- Weird glyphs/colors: try a modern terminal and a UTF-8 locale.
- Empty export: check your extension filters or selection; the TOC lists exactly what was found.
MIT. See LICENSE
.