Skip to main content

Convert Claude Code chat sessions to Markdown

Project description

cc2md

Convert Claude Code chat sessions to clean, readable Markdown — including subagent conversations.

Claude Code persists full chat history as JSONL files under ~/.claude/projects/. This tool reads those files and produces well-formatted Markdown with proper headings, code blocks, and collapsible sections for tool results and subagent conversations.

Install

pipx install cc2md

Or with pip:

pip install cc2md

Or run directly from source:

git clone https://github.com/kcxain/cc2md.git
cd cc2md
pip install -e .

Usage

List sessions

cc2md --list
#    Date                 ID           Title                                              Project
------------------------------------------------------------------------------------------------------------------------
1    2025-10-15 14:30     a1b2c3d4..   Refactor auth middleware                            dev/myapp
2    2025-10-14 09:15     e5f6a7b8..   Add user settings page                              dev/myapp
3    2025-10-13 16:45     c9d0e1f2..   Debug CI pipeline                                   dev/infra

Convert a session

# By index (from --list)
cc2md 1 -o chat.md

# By UUID prefix
cc2md a1b2c3 -o chat.md

# By title substring
cc2md "auth middleware" -o chat.md

# Most recent session
cc2md --latest -o chat.md

Filter by project

cc2md --list --project myapp
cc2md --latest --project myapp -o chat.md

Export all sessions

cc2md --all --output-dir ./exports/

Scan a custom directory

By default the tool reads from ~/.claude/projects/. Use --dir to point it at any directory:

# Scan a custom projects directory (subdirs are treated as project dirs)
cc2md --dir /path/to/projects --list

# Scan a single project directory (directly contains *.jsonl session files)
cc2md --dir ./my-project-export --list

The directory type is auto-detected: if *.jsonl files are found directly inside it, it is treated as a project directory; otherwise its subdirectories are treated as project directories.

Options

Flag Description
--list, -l List all available sessions
--latest Convert the most recent session
--all Convert all sessions
--project, -p Filter sessions by project path substring
--dir Directory to scan instead of ~/.claude/projects/
--output, -o Output file (default: stdout)
--output-dir, -d Output directory for --all mode
--no-subagents Exclude subagent conversations
--no-tool-results Exclude tool call results

Output format

  • User messages## User sections
  • Assistant messages## Assistant sections with text and tool calls
  • Tool results → collapsible <details> blocks
  • Subagent conversations → collapsible <details> blocks with full prompt/response
  • Code → fenced code blocks with language hints
  • Diffs → displayed as unified diff format
  • System tags (<ide_opened_file>, <system-reminder>) are stripped

How it works

Claude Code stores sessions at:

~/.claude/projects/<encoded-project-path>/<session-uuid>.jsonl

Each line is a JSON object: user messages, assistant messages (with tool_use blocks), tool_result responses, and metadata. Subagent conversations live in a subagents/ subdirectory alongside the main session file and are linked via progress records in the main JSONL.

Requirements

Python 3.10+ — no external dependencies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cc2md-0.2.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cc2md-0.2.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file cc2md-0.2.0.tar.gz.

File metadata

  • Download URL: cc2md-0.2.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for cc2md-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8af9f4032b617c1d6d5fed529b25c035ef848e921ce56d89c2e50cd30dbef39c
MD5 8d727d1744a522e8cd2d66b685a5f204
BLAKE2b-256 276b920a37646372e3d9315148e95539597c461a6c066c2dc56f861e2f539f58

See more details on using hashes here.

File details

Details for the file cc2md-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cc2md-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for cc2md-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df7851d04fd8bdef3c0e631c55d6792d7b4ebf8ae9c1686fd120e6462f309ac8
MD5 d1a2427e6bc23cbfabc353546589ede4
BLAKE2b-256 f01bd0a0c989e3a9ef1c5df91604acf8aac4e7c4684a32149970b5c8b4d3798d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page