CodeCapsule is a powerful Python utility that transforms entire project directories into a single, portable JSON file. Perfect for sharing code with AI models, archiving projects, or creating compact code representations.
- 🌐 Convert entire project structures to JSON
- 🧩 Supports multiple programming languages
- 🔍 Configurable file inclusion/exclusion
- 💡 Ideal for LLM code analysis and sharing
Install CodeCapsule using pip:
pip install codecapsule
# Convert current project to JSON
codecapsule
# Convert a specific project directory
codecapsule /path/to/your/project
# Save to a specific output file
codecapsule /path/to/project -o project_capsule.json
# Convert project directory and ignore additional patterns
codecapsule /path/to/project -i "*.log" -i "temp/"
CodeCapsule provides robust file processing with the following features:
-
🚫 Automatically excludes:
- Binary files
- Large executables (
.exe
,.dll
,.so
) - Compiled Python files (
.pyc
) - Version control directories (
.git
) - Virtual environments (
.venv
) - Development databases
-
🔍 File Content Detection
- Uses UTF-8 encoding
- Skips files that cannot be decoded
- Detects binary files using null-byte heuristic
[
{
"path": "src/main.py",
"content": "# Full contents of the Python file"
},
{
"path": "README.md",
"content": "# Project documentation"
}
]
- Large files may impact performance
- Only text-based files are processed
- Some binary or complex file types are automatically excluded
- 📤 Sharing entire project contexts with AI models
- 🗄️ Lightweight project archiving
- 🔬 Code analysis and exploration
BSD-3 License - See LICENSE
file for details.
- Python 3.8+
- No external dependencies
CodeCapsule is designed for code sharing and analysis. Always review JSON contents before sharing sensitive code.