| Crates.io | r2t |
| lib.rs | r2t |
| version | 0.4.0 |
| created_at | 2025-10-28 11:05:05.102506+00 |
| updated_at | 2025-12-11 13:26:49.509969+00 |
| description | A fast CLI tool to convert a repository's structure and contents into a single text file, useful for providing context to LLMs. |
| homepage | |
| repository | https://github.com/T00fy/r2t |
| max_upload_size | |
| id | 1904566 |
| size | 126,082 |
r2t is a blazing-fast command-line tool, written in Rust, that converts a directory's structure and contents into a single, well-structured text file. This is particularly useful for providing the full context of a codebase to a Large Language Model (LLM).
It is a Rust rewrite inspired by the original Python repo-to-text by Kirill Markin, with added features like out-of-the-box binary filtering and flexible configuration.
xml: (default) The original repo-to-text output, XML-like.yaml: clean, YAML-like output, slightly more verbose.json: JSON-like output..gitignore rules by default.*_test.go, src/test/**) and inline Rust test modules (#[cfg(test)]) to create a more concise context..r2t.yaml file to define custom ignore patterns and a default output format.You can really quickly try this out by just simply running
cargo install r2t
Or if you wanted to install from source:
git clone https://github.com/T00fy/r2t.git
cd r2t
cargo install --path .
The executable r2t will now be available in your Cargo bin path.Running r2t in a project directory will process it and create a timestamped output file (e.g., repo-to-text_1700000000.yaml) in the same directory. The default output format is XML.
# Process the current directory
r2t
# Process a specific directory
r2t /path/to/your-project
Usage: r2t [OPTIONS] [PATH]
Arguments:
[PATH] The root directory of the repository to process [default: .]
Options:
-o, --output-dir <OUTPUT_DIR> Directory to save the output file. Defaults to the input directory
--format <FORMAT> The output format for the final text file [possible values: yaml, json, xml]
--stdout Output the result to stdout instead of a file
--no-gitignore Do not respect .gitignore files for filtering
--skip-tests Skip including the content of test files and inline test modules
--create-settings Create a default .r2t.yaml settings file in the current directory
--global Use with --create-settings to create a global configuration file
-h, --help Print help
-V, --version Print version
Examples:
Create a JSON-like format file:
r2t --format json
Save to a different directory:
r2t /path/to/project --output-dir /path/to/output
Include files that are normally ignored by .gitignore:
r2t --no-gitignore
Exclude test file content: (Currently only java/go/rust/python is supported)
r2t --skip-tests
You can customize which files are included and the default format by creating a .r2t.yaml file in your project's root directory. r2t will automatically use it. You can also create a global config file.
To generate a default config file, run:
# Create .r2t.yaml in the current directory
r2t --create-settings
# Create a global config file in the system's config directory
r2t --create-settings --global
The default configuration looks like this:
# r2t settings file - https://github.com/T00fy/r2t
# Syntax: gitignore-style glob patterns
# The output format. Can be: yaml, json, xml
# Defaults to xml if not specified.
# format: xml
# Ignore files and directories for both the tree view and content sections.
ignore-tree-and-content:
- ".git/"
- "target/"
- "node_modules/"
- ".idea/"
- "*.log"
- ".terraform/"
# Ignore files only for the content section (they will still appear in the tree).
ignore-content:
- "LICENSE"
- "*.lock"
- ".r2t.yaml"
format: Sets the default output format when the --format flag is not used.ignore-tree-and-content: Patterns for files/directories to be completely excluded from both the directory tree and the content output.ignore-content: Patterns for files to be excluded from the content section, but still be visible in the directory tree. This is useful for things like lock files or licenses that you want the LLM to know exist but don't need the contents of.cargo build --release
The binary will be located at target/release/r2t.
Run the full test suite:
cargo test