cc-session-export
v1.0.0
Published
Export Claude Code sessions to Word (.docx) and PDF documents
Downloads
91
Maintainers
Readme
cc-session-export
Export Claude Code session files to Word (.docx) and PDF formats with full-text search, filtering, and interactive browsing.
Installation
Install globally:
npm install -g cc-session-exportOr clone and link locally:
git clone <repo>
cd sessionexport
npm install
npm linkQuick Start
Open the interactive browser:
cc-session-exportThis scans ~/.claude/projects/ for session .jsonl files and presents a numbered list. Use the commands below to navigate and export.
Interactive Browser Commands
When running cc-session-export without arguments:
- Number (e.g.,
1,3,10) — Export that session - Range (e.g.,
1-5) — Export sessions 1 through 5. You'll be prompted to merge them into a single document s— Search by text across all session contentf— Filter by project name (substring match)a— Export all sessionsn— Next pagep— Previous pager— Reset filters/searchq— Quit
The list shows project name, session age, file size, and a preview of the first few messages.
Command-Line Flags
# Export the 1 most recent session
cc-session-export --latest
# Export the 10 most recent sessions, merged into one document
cc-session-export --latest 10 --merge
# Filter by project name (substring match)
cc-session-export --project myapp
# Full-text search across all sessions
cc-session-export --search "user authentication"
# Export all sessions at once
cc-session-export --all
# Compact format: strips tool calls/results, conversation only
cc-session-export --compact
# Keep all message types but remove tool I/O blocks
cc-session-export --no-tools
# Export as PDF instead of docx
cc-session-export --pdf
# Custom output directory (default: ./cc-session-exports)
cc-session-export --output ~/my-exports
# Show help
cc-session-export --helpFlags combine freely:
cc-session-export --project myapp --compact --merge --latest 3 --pdfThis exports the 3 most recent sessions from the "myapp" project, strips tool I/O, merges them into a single PDF, and uses compact formatting.
What the Output Looks Like
Each exported document is professionally formatted with:
- Color-coded sections: User messages in blue, assistant responses in green, tool calls in orange
- Dark-themed code blocks: Syntax-highlighted code with a slate background for readability
- Metadata tables: Timestamp, token counts, model, temperature, and other execution details
- Headers and footers: Page numbers on every page
- Clean typography: Proper heading hierarchy, readable font sizing, appropriate spacing
Documents are optimized for both screen viewing and printing.
How It Works
The tool scans your ~/.claude/projects/ directory for .jsonl session files (the format Claude Code uses to store conversation history). It parses each file, extracts messages with their roles (user, assistant, tool calls), metadata, and code execution results. The interactive browser lets you search, filter, and select sessions. When you choose to export, the tool formats everything into a structured .docx or .pdf document with color coding, tables for metadata, and proper typography. You can merge multiple sessions into one document for context-heavy exports.
Tips
Feeding to other AIs: Use
--compactwhen exporting sessions to feed to ChatGPT, Gemini, or Claude. This strips tool calls and results, keeping only the conversation, which reduces token count and improves clarity.Multi-session project context: Use
--mergeto combine multiple related sessions into one document. Useful for generating complete project documentation or context files.Search before export: Use
sin the interactive browser to find sessions containing specific keywords before exporting. Saves time when you have many sessions.Filtering by project: Use
for--projectto narrow down to a specific project folder, then export in batch with--latest 5 --merge.PDF vs DOCX: Use
--pdfwhen you need a format that can't be edited and distributes cleanly. Use.docxwhen you might want to edit or add notes to the export.Preview before export: The interactive browser shows a preview of each session (first few messages) so you can confirm you're exporting the right one before committing.
Requirements
- Node.js 18+
docx- Word document generationpdfkit- PDF generation
License
MIT
