Skip to main content

Convert source code directories into a single Markdown file

Project description

src2md

PyPI License

Sometimes you just want to paste a codebase into a chatbot. src2md converts a source code directory into a single Markdown file -- that's it.

No frameworks. No token optimizers. No LLM integrations. Just your code in a format any LLM can read.

Install

pip install src2md

Usage

# Output to stdout (pipe to clipboard, redirect to file, etc.)
src2md /path/to/project | pbcopy
src2md /path/to/project > output.md

# Or save to a file directly
src2md /path/to/project -o output.md

# Include recent git history for extra context
src2md /path/to/project --log

That gives you a Markdown file with every matching file in fenced code blocks with syntax highlighting, respecting your .gitignore automatically.

Options

src2md path [options]

-o, --out FILE            Output file (default: stdout)
--include PATTERN ...     File patterns to include (default: common extensions)
--exclude PATTERN ...     File/dir patterns to exclude (default: .* hidden files)
--log [N]                 Include recent git history (default: 25 commits)

Examples

# Only Python files
src2md . --include '*.py'

# Everything except tests and docs
src2md . --exclude tests docs

# Python files with last 50 commits of history
src2md . --include '*.py' --log 50

.gitignore

If your project is a git repo, src2md automatically respects .gitignore. No need to configure anything -- node_modules/, __pycache__/, dist/, etc. are excluded if your .gitignore says so.

For non-git directories, use --exclude to skip what you don't need.

Supported languages

Python, C/C++, JavaScript/TypeScript, Java, Go, Ruby, PHP, Swift, Kotlin, Rust, R, Bash, SQL, HTML, CSS, SCSS, JSON, XML, YAML, TOML, Markdown, LaTeX, Lua, Zig, Nim, Elixir, Erlang, Haskell, OCaml, Scala, Clojure, Dart, Vue, Svelte, and more.

Why?

Agentic coding tools (Claude Code, Cursor, etc.) can browse your repo directly. But sometimes you're just talking to a plain chatbot -- ChatGPT, Claude.ai, etc. -- and you want to give it your whole project as context. Copy-pasting files one by one is tedious. src2md does it in one command.

This can also breathe some life into older or smaller LLMs for coding tasks -- give them the full project context they'd otherwise never see. Just be aware that src2md does nothing smart about context limits. A large repo produces a large file. If your LLM has a small context window, use --include and --exclude to narrow things down.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

src2md-3.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

src2md-3.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file src2md-3.1.1.tar.gz.

File metadata

  • Download URL: src2md-3.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for src2md-3.1.1.tar.gz
Algorithm Hash digest
SHA256 29d712cf8a510f8991a56a73abaa19c88387f3c4974326ac9f164283c8c700f1
MD5 e189c98863ca438f4bd7adfaf7656b9d
BLAKE2b-256 daaae2aa5c3250455cb8c541d943ae89ea9e2b78af401959de9000cdd8ae8c90

See more details on using hashes here.

File details

Details for the file src2md-3.1.1-py3-none-any.whl.

File metadata

  • Download URL: src2md-3.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for src2md-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4c99497ba7e613fa583e205d512918ee2ad87d13e0b7e50a516d8fd2b188d28
MD5 7e0588e30a6bd19fb1e8263d66d92c4a
BLAKE2b-256 fe5dd1656e1e998507195d0d5842599fb8d224220b7537623ed2004392a51ea5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page