Code2Prompt

Code2Prompt

★ 4 🔖 2500 saves 💰 Free DevtoolsGitHub

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.

Overview

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.

Key Features

  • Convert a whole codebase into one LLM-ready prompt in seconds
  • Respects .gitignore, with glob include/exclude filters
  • Handlebars prompt templating to frame context your way
  • Accurate token counting so you know the prompt fits the context window
  • Optional line numbers, source-tree view and clipboard/file/stdout output
  • Written in Rust — fast on large repositories

💳 Pricing

Code2Prompt is completely free and open source under the MIT license.

Who Is It For

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.

🚀 Visit Code2Prompt Official Site

🚩 Report an issue