Code2Prompt is an open-source command-line tool that converts an entire codebase into a single, well-structured LLM prompt. Point it at a project and it walks the source tree, respects your ignore rules, renders files through prompt templates, counts the tokens — and hands you one prompt ready to paste into ChatGPT, Claude or any other model. The project has earned about 7,700 stars on GitHub and is actively maintained in 2026.
Feeding code to an LLM by hand is tedious and error-prone: files get missed, binary junk sneaks in, and you never know the token cost until the model complains. Code2Prompt, written in Rust and therefore fast even on large repositories, automates the whole ritual. It honors .gitignore, supports glob patterns to include or exclude paths, can add line numbers, and uses Handlebars-style templates so you control exactly how the prompt is framed — instructions at the top, tree in the middle, files after. Token counting with real tokenizers tells you up front whether the result fits your model’s context window, and output can go to the clipboard, a file or stdout for piping into other tools. It has become a standard utility in the LLM-assisted development workflow, especially for code review, documentation and “explain this repo” sessions.
Code2Prompt is completely free and open source under the MIT license.
Code2Prompt is for developers who regularly give LLMs whole-project context — for reviews, debugging, documentation or onboarding — and want it done reliably in one command.