src2md
A CLI tool that bundles source files into a single Markdown document. You can also restore the original files from the Markdown output.
Useful for sharing code with LLMs, creating documentation snapshots, or archiving projects in a readable format.
Note: This project was developed with AI assistance. The codebase is tested but may have rough edges.
Installation
Or download a binary from Releases.
Quick Start
# Bundle current directory into Markdown
# Only include certain file types
# Restore files from a bundle
What It Does
- Walks directories and collects text files
- Wraps each file in a fenced code block with syntax highlighting
- Handles nested code blocks safely (uses extended backtick fences)
- Skips binary files (lists them without content)
- Can restore the original files from the Markdown output
What It Excludes (by default)
- Hidden files and directories (
.git,.env, etc.) - Lock files (
Cargo.lock,package-lock.json,yarn.lock, etc.) - Its own previous output files
CLI Options
src2md [OPTIONS] [PATHS]...
Arguments:
[PATHS]... Files or directories to include
Options:
-o, --output <FILE> Output file (default: {project}_{timestamp}.md)
--ignore-file <FILE> Custom ignore file (like .gitignore)
-e, --ext <EXT> Filter by extensions (comma-separated: rs,ts,js)
-v, --verbose Increase verbosity (-v, -vv, -vvv)
--restore <FILE> Restore files from a Markdown bundle
--restore-path <DIR> Where to restore files
--fail-fast Stop on first error
-h, --help Print help
Library Usage
use ;
use HashSet;
use PathBuf;
async
See docs.rs for full API documentation.
License
MIT