Optimize bloated JSONL session files by truncating large tool results while preserving conversation continuity.
Transform 2MB+ session files into lean, fast-loading versions without losing context. Built for Claude Code, Clawdbot sessions, and any JSONL-based chat logs.
# Analyze your sessions
python analyze-sessions.py ~/.claude/projects/
# Preview changes (safe, no modifications)
python truncate-sessions.py ~/.claude/projects/ --dry-run
# Apply truncation with automatic backups
python truncate-sessions.py ~/.claude/projects/ --confirmcd web-ui
npm install && npm run dev
# Open http://localhost:3000Drag & drop your JSONL files, analyze bloat, download optimized versions. Perfect for one-off files or non-technical users.
Claude Code session files balloon to 2MB+ because tool results contain massive outputs - file contents, logs, command output. This kills context loading speed and wastes tokens.
Surgical truncation: Keep first 2.5KB + last 2.5KB of large tool results, insert a size marker. Preserves conversation flow, cuts 90% of bloat.
Before (bloated tool result):
{"role":"tool","tool_result":"File contents:\nline 1\nline 2\n...50,000 lines of logs..."}After (truncated):
{"role":"tool","tool_result":"File contents:\nline 1\nline 2\n\n[TRUNCATED: 197KB removed, keeping first + last 2.5KB each]\n\n...line 49,999\nline 50,000"}| File | Before | After | Saved |
|---|---|---|---|
| session_abc123 | 2.3MB | 180KB | 92% |
| session_def456 | 800KB | 95KB | 88% |
- Parse each JSONL line and identify tool results over threshold (default 5KB)
- Truncate large results: keep first 2.5KB + last 2.5KB, insert size marker
- Preserve all user messages, assistant responses, and conversation metadata
- Large tool results over 5KB (configurable via
--threshold) - Preserves first and last portions with size marker
- Never touches user messages, assistant responses, or metadata
- Atomic backups - Timestamped backups before any modification
- Dry-run mode - Preview all changes before applying
- JSON validation - Validates output before writing
- Rollback ready - Restore from
.backup_*files anytime
CLI Tools:
- Python 3.9+ (no external dependencies)
Web Interface:
- Node.js 18+
- npm or yarn
MIT