c2md


Namec2md JSON
Version 1.1.1 PyPI version JSON
download
home_pageNone
SummaryTool to convert Context7 formatted llms.txt to locally organized markdown library documentation
upload_time2025-07-13 05:38:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords cli context7 converter documentation markdown
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Context7 to Markdown (`c2md`)

A blazing fast tool that converts Context7 to organized markdown documentation with automatic directory structure, multi-language parsing support, and table of contents generation. Supports both local files and direct URLs from Context7.com.

Install with pip
```bash
pip install c2md
```
Install with uv
```bash
uv pip install c2md
```
*or*
```bash
uvx c2md https://context7.com/org/project
```

## Why `c2md`? πŸ€”

MCP servers are fairly new and are quite rudimentary. They introduce latency, increase prompt size, consume tokens on every request, and, in the case of Context7, require network calls for each library lookup. Additionally, Context7's MCP server uses natural language search that can miss relevant sections or return results you don't even need.

With `c2md`, you convert a library <ins>once</ins> per project and reference it locally. Instead of making MCP calls that cost 4,000-20,000 tokens per search, you attach the generated 000-index.md (typically costs less than Context7's `resolve-library-id` alone) directly to your agent. The agent gets complete context without network delays or token waste on repeated or bad searches.

This tool excels when dealing with large libraries like Neon, which has around 240 sections (~520,000 tokens). The locally generated index provides instant, inexpensive library context to any section while consuming ~50% fewer tokens than equivalent MCP operations. You can even pass the table of contents or specific sections from the library via a rule in your favorite AI IDE.

If that didn't sell you, `c2md`:

- **βš“ converts Context7 to local markdown**
- **🧠 logically organizes the library into sections with sequential file naming**
- **πŸ—¨οΈ consolidates multi-language sections into a single document**
- **πŸ“œ generates Table of contents = easy context for your agent**
- **πŸ—ΊοΈ maps source URLs to appropriate file paths and names** 
- **🏎️ is fast as hell**

## Installation

#### Using pip

```bash
pip install c2md
```

#### Using uv

```bash
uv pip install c2md
```
*or*
```bash
uvx c2md https://context7.com/org/project
```

## Requirements

- Python 3.8 or higher
- No external dependencies required unless developing

## Usage

From local file - output defaults to `./output/`
```bash
c2md /path/to/llms.txt
```
From Context7 standard URL - output defaults to `./{project}/`
```bash
c2md https://context7.com/{org}/{project}
```
From Context7 raw URL with tokens query
```bash
c2md https://context7.com/{org}/{project}/llms.txt?tokens=173800
```

### Tips

##### 1. Not all Context7 libraries are created equal. 

Most of the time, if it's generated from a Github repository, it is not the full documentation. That being said, many repositories are solely for documentation or include a documentation app/package. For instance:

**βœ… GOOD**: context7/nextjs
**❌ BAD**:  vercel/next.js

### Advanced Usage

```bash
# Specify output directory, 001-index.md (ToC) generated in output root
c2md /path/to/llms.txt -d /path/to/output

# From Context7 raw URL with output directory
c2md https://context7.com/{org}/{project}/llms.txt -d .docs/neon

# Disable ToC generation
c2md /path/to/llms.txt -nt

# Disable numbered prefixes ("001-")
c2md /path/to/llms.txt -np

# Full example with all options, no table of contents
c2md https://context7.com/llmstxt/better-auth_com-llms.txt/llms.txt?tokens=1000000 -d /path/to/output -nt -np
```

### Command Line Options

- `{input_file|input_url}`: Context7 formatted llms.txt or Context7 URL (REQUIRED)
- `-d, --directory`: Output directory. Defaults to the library name if a URL is passed. If a file is passed, defaults to "output"
- `-nt, --no-toc`: Disable table of contents generation in documentation root
- `-np, --no-prefix`: Disable "000-" prefix file naming
- `-h, --help`: Show help message and exit

## Bug Reports

If you encounter any issues, please report them on the [GitHub Issues](https://github.com/crisp-sh/context7-to-markdown/issues) page.

<details>
    <summary>
    <strong>Developing locally & contributing</strong>
    </summary>

### Contributing 🀝

Contributions are welcome! Please feel free to submit a PR if you would like to contribute or have an issue.

### Development Installation

```bash
# Clone the repository
git clone https://github.com/crisp-sh/context7-to-markdown.git
cd context7-to-markdown

# Install in development mode
pip install -e .
```

### Output Structure

The tool creates an organized directory structure:

```
output/
β”œβ”€β”€ 001-index.md                    # Table of contents (if enabled)
β”œβ”€β”€ domain1.com/
β”‚   β”œβ”€β”€ section1/
β”‚   β”‚   β”œβ”€β”€ 001-page1.md
β”‚   β”‚   └── 002-page2.md
β”‚   └── section2/
β”‚       └── 001-page3.md
└── domain2.com/
    └── docs/
        └── 001-guide.md
```

### Context7 Format

The tool processes Context7 format files, which should contain entries with:
- **SOURCE**: URL or source identifier
- **CONTENT**: The actual content to be converted
- **TITLE**: Optional title for the content
- **LANGUAGE**: Denotes a multi-language document

### Architecture

The tool consists of several modular components:

- **Parser**: Processes Context7 format files
- **URL Mapper**: Maps source URLs to file paths
- **File Organizer**: Organizes content into directory structures
- **Markdown Writer**: Generates clean markdown files
- **Index Generator**: Creates table of contents

### Testing

Run the test suite using Hatch:

```bash
# Run tests
hatch run test

# Run tests with coverage
hatch run test-cov

# Run specific test file
hatch run test tests/test_specific.py
```

### Legacy Testing

```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
python -m unittest discover tests

# Run tests with coverage
python -m unittest discover tests
```

### Releasing

This project uses automated versioned releases with [Hatch](https://hatch.pypa.io/) for version management.

#### Quick Release

```bash
# Create a patch release (0.1.0 β†’ 0.1.1)
hatch run release patch

# Create a minor release (0.1.0 β†’ 0.2.0)
hatch run release minor

# Create a major release (0.1.0 β†’ 1.0.0)
hatch run release major
```

#### Development Setup

```bash
# Clone the repository
git clone https://github.com/crisp-sh/context7-to-markdown.git
cd context7-to-markdown

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install
pip install -e .
```

#### Running Tests

```bash
# Run all tests with Hatch
hatch run test

# Run specific test file
hatch run test tests/test_specific.py

# Run tests with coverage
hatch run test-cov
```
</details>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "c2md",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cli, context7, converter, documentation, markdown",
    "author": null,
    "author_email": "crisp-sh <s@crisp.sh>",
    "download_url": "https://files.pythonhosted.org/packages/fa/3e/5557c4ef0a0baa924373ee90bcf4cf8ac118ad849acdac97dd855f0867e9/c2md-1.1.1.tar.gz",
    "platform": null,
    "description": "# Context7 to Markdown (`c2md`)\n\nA blazing fast tool that converts Context7 to organized markdown documentation with automatic directory structure, multi-language parsing support, and table of contents generation. Supports both local files and direct URLs from Context7.com.\n\nInstall with pip\n```bash\npip install c2md\n```\nInstall with uv\n```bash\nuv pip install c2md\n```\n*or*\n```bash\nuvx c2md https://context7.com/org/project\n```\n\n## Why `c2md`? \ud83e\udd14\n\nMCP servers are fairly new and are quite rudimentary. They introduce latency, increase prompt size, consume tokens on every request, and, in the case of Context7, require network calls for each library lookup. Additionally, Context7's MCP server uses natural language search that can miss relevant sections or return results you don't even need.\n\nWith `c2md`, you convert a library <ins>once</ins> per project and reference it locally. Instead of making MCP calls that cost 4,000-20,000 tokens per search, you attach the generated 000-index.md (typically costs less than Context7's `resolve-library-id` alone) directly to your agent. The agent gets complete context without network delays or token waste on repeated or bad searches.\n\nThis tool excels when dealing with large libraries like Neon, which has around 240 sections (~520,000 tokens). The locally generated index provides instant, inexpensive library context to any section while consuming ~50% fewer tokens than equivalent MCP operations. You can even pass the table of contents or specific sections from the library via a rule in your favorite AI IDE.\n\nIf that didn't sell you, `c2md`:\n\n- **\u2693 converts Context7 to local markdown**\n- **\ud83e\udde0 logically organizes the library into sections with sequential file naming**\n- **\ud83d\udde8\ufe0f consolidates multi-language sections into a single document**\n- **\ud83d\udcdc generates Table of contents = easy context for your agent**\n- **\ud83d\uddfa\ufe0f maps source URLs to appropriate file paths and names** \n- **\ud83c\udfce\ufe0f is fast as hell**\n\n## Installation\n\n#### Using pip\n\n```bash\npip install c2md\n```\n\n#### Using uv\n\n```bash\nuv pip install c2md\n```\n*or*\n```bash\nuvx c2md https://context7.com/org/project\n```\n\n## Requirements\n\n- Python 3.8 or higher\n- No external dependencies required unless developing\n\n## Usage\n\nFrom local file - output defaults to `./output/`\n```bash\nc2md /path/to/llms.txt\n```\nFrom Context7 standard URL - output defaults to `./{project}/`\n```bash\nc2md https://context7.com/{org}/{project}\n```\nFrom Context7 raw URL with tokens query\n```bash\nc2md https://context7.com/{org}/{project}/llms.txt?tokens=173800\n```\n\n### Tips\n\n##### 1. Not all Context7 libraries are created equal. \n\nMost of the time, if it's generated from a Github repository, it is not the full documentation. That being said, many repositories are solely for documentation or include a documentation app/package. For instance:\n\n**\u2705 GOOD**: context7/nextjs\n**\u274c BAD**:  vercel/next.js\n\n### Advanced Usage\n\n```bash\n# Specify output directory, 001-index.md (ToC) generated in output root\nc2md /path/to/llms.txt -d /path/to/output\n\n# From Context7 raw URL with output directory\nc2md https://context7.com/{org}/{project}/llms.txt -d .docs/neon\n\n# Disable ToC generation\nc2md /path/to/llms.txt -nt\n\n# Disable numbered prefixes (\"001-\")\nc2md /path/to/llms.txt -np\n\n# Full example with all options, no table of contents\nc2md https://context7.com/llmstxt/better-auth_com-llms.txt/llms.txt?tokens=1000000 -d /path/to/output -nt -np\n```\n\n### Command Line Options\n\n- `{input_file|input_url}`: Context7 formatted llms.txt or Context7 URL (REQUIRED)\n- `-d, --directory`: Output directory. Defaults to the library name if a URL is passed. If a file is passed, defaults to \"output\"\n- `-nt, --no-toc`: Disable table of contents generation in documentation root\n- `-np, --no-prefix`: Disable \"000-\" prefix file naming\n- `-h, --help`: Show help message and exit\n\n## Bug Reports\n\nIf you encounter any issues, please report them on the [GitHub Issues](https://github.com/crisp-sh/context7-to-markdown/issues) page.\n\n<details>\n    <summary>\n    <strong>Developing locally & contributing</strong>\n    </summary>\n\n### Contributing \ud83e\udd1d\n\nContributions are welcome! Please feel free to submit a PR if you would like to contribute or have an issue.\n\n### Development Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/crisp-sh/context7-to-markdown.git\ncd context7-to-markdown\n\n# Install in development mode\npip install -e .\n```\n\n### Output Structure\n\nThe tool creates an organized directory structure:\n\n```\noutput/\n\u251c\u2500\u2500 001-index.md                    # Table of contents (if enabled)\n\u251c\u2500\u2500 domain1.com/\n\u2502   \u251c\u2500\u2500 section1/\n\u2502   \u2502   \u251c\u2500\u2500 001-page1.md\n\u2502   \u2502   \u2514\u2500\u2500 002-page2.md\n\u2502   \u2514\u2500\u2500 section2/\n\u2502       \u2514\u2500\u2500 001-page3.md\n\u2514\u2500\u2500 domain2.com/\n    \u2514\u2500\u2500 docs/\n        \u2514\u2500\u2500 001-guide.md\n```\n\n### Context7 Format\n\nThe tool processes Context7 format files, which should contain entries with:\n- **SOURCE**: URL or source identifier\n- **CONTENT**: The actual content to be converted\n- **TITLE**: Optional title for the content\n- **LANGUAGE**: Denotes a multi-language document\n\n### Architecture\n\nThe tool consists of several modular components:\n\n- **Parser**: Processes Context7 format files\n- **URL Mapper**: Maps source URLs to file paths\n- **File Organizer**: Organizes content into directory structures\n- **Markdown Writer**: Generates clean markdown files\n- **Index Generator**: Creates table of contents\n\n### Testing\n\nRun the test suite using Hatch:\n\n```bash\n# Run tests\nhatch run test\n\n# Run tests with coverage\nhatch run test-cov\n\n# Run specific test file\nhatch run test tests/test_specific.py\n```\n\n### Legacy Testing\n\n```bash\n# Install development dependencies\npip install -e \".[dev]\"\n\n# Run tests\npython -m unittest discover tests\n\n# Run tests with coverage\npython -m unittest discover tests\n```\n\n### Releasing\n\nThis project uses automated versioned releases with [Hatch](https://hatch.pypa.io/) for version management.\n\n#### Quick Release\n\n```bash\n# Create a patch release (0.1.0 \u2192 0.1.1)\nhatch run release patch\n\n# Create a minor release (0.1.0 \u2192 0.2.0)\nhatch run release minor\n\n# Create a major release (0.1.0 \u2192 1.0.0)\nhatch run release major\n```\n\n#### Development Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/crisp-sh/context7-to-markdown.git\ncd context7-to-markdown\n\n# Create a virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Install\npip install -e .\n```\n\n#### Running Tests\n\n```bash\n# Run all tests with Hatch\nhatch run test\n\n# Run specific test file\nhatch run test tests/test_specific.py\n\n# Run tests with coverage\nhatch run test-cov\n```\n</details>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tool to convert Context7 formatted llms.txt to locally organized markdown library documentation",
    "version": "1.1.1",
    "project_urls": {
        "Bug Reports": "https://github.com/crisp-sh/context7-to-markdown/issues",
        "Homepage": "https://github.com/crisp-sh/context7-to-markdown",
        "Source": "https://github.com/crisp-sh/context7-to-markdown"
    },
    "split_keywords": [
        "cli",
        " context7",
        " converter",
        " documentation",
        " markdown"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "033398f50da56929dcefcb0f324a8e3a5183d387b0514108d16e45d83ec4e486",
                "md5": "eafb8755f01bdef275c3bb24d64c6702",
                "sha256": "08c5a51cb28cff5c57de76dd6ef3f534747e8b48edc119511346baaf920da94c"
            },
            "downloads": -1,
            "filename": "c2md-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eafb8755f01bdef275c3bb24d64c6702",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 25072,
            "upload_time": "2025-07-13T05:38:01",
            "upload_time_iso_8601": "2025-07-13T05:38:01.689278Z",
            "url": "https://files.pythonhosted.org/packages/03/33/98f50da56929dcefcb0f324a8e3a5183d387b0514108d16e45d83ec4e486/c2md-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fa3e5557c4ef0a0baa924373ee90bcf4cf8ac118ad849acdac97dd855f0867e9",
                "md5": "94ce996b04936abadbf101872674ea7e",
                "sha256": "7c0cd43b29d2fb2dd894e58251e403d7daa1a897235bfa9201e3e8156e3ffb94"
            },
            "downloads": -1,
            "filename": "c2md-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "94ce996b04936abadbf101872674ea7e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 21006,
            "upload_time": "2025-07-13T05:38:03",
            "upload_time_iso_8601": "2025-07-13T05:38:03.185573Z",
            "url": "https://files.pythonhosted.org/packages/fa/3e/5557c4ef0a0baa924373ee90bcf4cf8ac118ad849acdac97dd855f0867e9/c2md-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-13 05:38:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crisp-sh",
    "github_project": "context7-to-markdown",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "c2md"
}
        
Elapsed time: 0.98084s