A Rust-based command-line tool that scans a local repository, extracts just the code files (for ~20 popular languages), and produces a single Markdown file.
It helps you ignore common dependency folders (e.g., node_modules
, venv
, target
) and dotfiles while preserving the essential directory structure and file contents. Useful for quickly sharing or analyzing a project in a single file, or for feeding that file to Large Language Models (LLMs).
- Single-File Snapshot: Gather all code (excluding dependencies) in one Markdown for easy review or sharing.
- Automated Filtering: Respects
.gitignore
, common hidden folders, and typical dependency directories to avoid clutter. - Cross-Language Support: Recognizes ~20 popular programming languages (by file extension) and ignores the rest.
- Convenient Output: Generate Markdown for easy reading, without manual or complicated steps.
- Install Rust (with rustup) if you haven’t already:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Clone or download this repository (or place the two main files,
Cargo.toml
andsrc/main.rs
, in a new directory). - In that directory, run:
This creates a release build in
cargo build --release
target/release/r2md
(on macOS/Linux) ortarget\release\r2md.exe
(on Windows).
-
Basic usage (scan the current directory, output to
r2md_output.md
):cargo run
or, if you prefer the release binary:
./target/release/r2md
(on Windows:
.\target\release\r2md.exe
). -
Specifying a repo path and custom output:
./r2md /path/to/your/repository -o myoutput.md
This scans the specified directory, ignoring non-code files, and writes the result to
myoutput.md
. -
Include a PDF using the
-p
or--pdf
flag:./r2md . --pdf
This generates both
r2md_output.md
andr2md_output.pdf
.
Or if you specify an output name, e.g.-o myexport.md
, amyexport.pdf
will also be produced.
Usage: r2md [PATH] [OPTIONS]
Arguments:
[PATH] Path to the repository (default: current directory)
Options:
-o, --output <FILE> Output Markdown file name (default: r2md_output.md)
-p, --pdf Also produce a PDF file (default: r2md_output.pdf if no output is specified)
-h, --help Print help information
-V, --version Print version information
- Build the release version:
cargo build --release
- Copy the binary (
r2md
) to a directory in your$PATH
, for example:sudo cp target/release/r2md /usr/local/bin/
- Now you can run:
r2md --help
- Build the release version:
cargo build --release
- You will get an executable at
target\release\r2md.exe
. - Copy or move this
.exe
to a folder in yourPATH
. For example:- Create a folder
C:\bin
if it doesn’t exist. - Copy:
copy .\target\release\r2md.exe C:\bin\
- Add
C:\bin
to your Windows systemPATH
if it isn’t there already.
- Create a folder
- You can now run:
from any folder.
r2md --help