npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

c2ctx

v2.0.0

Published

Convert source code folders into LLM-optimized context files with intelligent compression and analysis

Downloads

6

Readme

🤖 c2ctx - Code to Context Converter

npm version License: MIT

Convert your source code folders into LLM-optimized context files with intelligent compression, statistics, and multiple output formats. Perfect for feeding code context to ChatGPT, Claude, or other AI models.

✨ Features

  • 🗜️ Smart Compression: Removes unnecessary whitespace and comments while preserving code structure
  • 📊 Project Analytics: Detailed statistics about your codebase (files, lines, languages)
  • 🎯 Language Detection: Automatically detects and categorizes 15+ programming languages
  • 📁 Large File Handling: Summarizes large files instead of including full content
  • 🚫 Smart Ignoring: Comprehensive default ignore list + custom patterns
  • 📝 Multiple Formats: Output in Markdown or plain text
  • Fast & Lightweight: Zero dependencies, pure Node.js

🚀 Quick Start

Global Installation

npm install -g c2ctx
c2ctx ./src

NPX (Recommended - No Installation)

npx c2ctx ./src

Local Installation

npm install --save-dev c2ctx
npx c2ctx ./src

📖 Usage

Basic Usage

# Convert src folder to context.txt
c2ctx ./src

# Also available as full name
code-to-context ./src

Advanced Usage

# Custom output file and format
c2ctx ./src --output my-context.md --format markdown

# Ignore additional files/patterns
c2ctx ./src --ignore "*.test.js" "temp" "__tests__"

# Adjust max file size (default: 50KB)
c2ctx ./src --max-size 100000

# Disable compression and metrics
c2ctx ./src --no-compression --no-metrics

# Quiet mode
c2ctx ./src --quiet

🎛️ Options

| Option | Alias | Default | Description | | ------------------ | ----- | ------------- | ------------------------------------------ | | --output | -o | context.txt | Output file name | | --format | -f | markdown | Output format (markdown or text) | | --ignore | | [] | Additional files/patterns to ignore | | --max-size | | 50000 | Max file size before summarization (bytes) | | --no-compression | | false | Disable code compression | | --no-metrics | | false | Disable statistics generation | | --quiet | -q | false | Suppress progress messages | | --help | -h | | Show help message |

📁 Default Ignore List

The tool automatically ignores common files and directories:

.git, node_modules, .vscode, .idea, dist, build, coverage
.env*, *.log, package-lock.json, yarn.lock, pnpm-lock.yaml
.DS_Store, thumbs.db, *.tmp, *.temp, .cache, .next
__pycache__, *.pyc, .pytest_cache, venv, env
target, *.class, .gradle, bin, obj

🗂️ Supported Languages

  • Web: JavaScript, TypeScript, HTML, CSS, SCSS
  • Backend: Python, Java, C++, C#, Go, Rust, PHP, Ruby
  • Mobile: Swift, Kotlin
  • Config: JSON, YAML, TOML, ENV files
  • Others: Shell scripts, SQL, Docker, Markdown

📊 Example Output

# 🤖 LLM Context File

Generated: 2024-01-15T10:30:00.000Z
Source: /path/to/your/project

## 📦 Project: my-awesome-app

- **Version**: 1.0.0
- **Description**: An awesome application
- **Main**: index.js

## 📁 src/index.js

```javascript
import express from "express";
const app = express();
// ... rest of your code
```

📊 Project Statistics

  • Total Files: 25
  • Total Lines: 1,250
  • Total Size: 125.5 KB
  • Large Files Skipped: 0

Language Breakdown:

  • javascript: 15 files
  • typescript: 8 files
  • json: 2 files

## 🔧 Programmatic Usage

```javascript
const CodeContextConverter = require('c2ctx');

const converter = new CodeContextConverter({
    maxFileSize: 100000,
    enableCompression: true,
    format: 'markdown'
});

const success = converter.createContextFile(
    './src',
    'output.md',
    ['custom-ignore-pattern'],
    false // quiet mode
);

🤝 Use Cases

  • LLM Context: Feed your codebase to ChatGPT, Claude, or other AI models
  • Code Reviews: Generate comprehensive code summaries
  • Documentation: Create project overviews with statistics
  • Onboarding: Help new team members understand project structure
  • Analysis: Get insights into your codebase composition

🛠️ Development

git clone https://github.com/yourusername/c2ctx.git
cd c2ctx
npm test

📄 License

MIT © [Your Name]

🤔 FAQ

Q: Why is my output file large? A: Try reducing --max-size or adding more patterns to --ignore.

Q: Can I use this in CI/CD? A: Yes! Use --quiet flag for clean automation.

Q: Does it work with monorepos? A: Absolutely! Point it to any folder structure.

Q: How does compression work? A: Removes excessive whitespace, empty lines, and non-essential comments while preserving code structure.


Found this useful? Star the repo!