Claude Code JSONL Repair Tool - Clean up and fix Claude Code session files
This tool fixes the issue reported in anthropics/claude-code#10199:
Session JSONL files become corrupted or bloated
- Truncated JSON lines after crashes or force stops (
Ctrl+C)- Excessive
thinkingcontent consuming disk space (3-10x actual output)- Unable to resume sessions due to parse errors
A command-line tool to repair and optimize Claude Code session JSONL files. Claude Code stores conversation history in .jsonl files under ~/.claude/projects/. These files often contain:
- Thinking content - AI's internal reasoning process (3-10x larger than actual output)
- Corrupted JSON - Truncated lines from crashes or force stops
- Invalid entries - Empty lines, control characters
This tool fixes all these issues automatically.
| Item | Version |
|---|---|
| Platform | macOS |
| Tested on | macOS 15.0 (24A335) |
| Python | 3.8+ |
| Claude Code | 1.0+ |
| Feature | Description |
|---|---|
| Remove thinking | Strip thinking and redacted_thinking blocks |
| Auto-fix JSON | Repair truncated, malformed JSON lines |
| Fuzzy search | Find projects by keyword |
| Batch mode | Fix all projects with --all |
# Clone
git clone https://github.com/mason0510/fix-jsonl.git
cd fix-jsonl
# Install globally
chmod +x fix-jsonl.py
sudo ln -sf $(pwd)/fix-jsonl.py /usr/local/bin/fix-jsonl
# Or just run directly
python3 fix-jsonl.py <keyword># Fix by keyword (fuzzy match)
fix-jsonl wechat
fix-jsonl my-project
# Fix all projects
fix-jsonl --all
# Fix specific path
fix-jsonl /path/to/file.jsonl
fix-jsonl ~/.claude/projects/my-project
# Show help
fix-jsonl📁 -Users-demo-my-awesome-project
✓ session-abc123.jsonl: thinking:15, fixed:2 (954.2KB)
✓ session-def456.jsonl: thinking:8 (237.7KB)
==================================================
Fixed: 2 files | Saved: 1.16 MB
| Aspect | Score |
|---|---|
| Feature Completeness | 85/100 |
| Practical Value | 95/100 |
Why 95/100 practical value?
- Claude's thinking process is often 3-10x longer than actual output
- Removing it significantly saves disk space
- Auto-fix prevents parsing errors in downstream tools
-
--dry-runpreview mode -
--backupcreate.bakfiles -
--compressoutput to.gz -
--keep-thinkingfix format only - Parallel processing for
--all
本工具修复 anthropics/claude-code#10199 中报告的问题:
会话 JSONL 文件损坏或膨胀
- 崩溃或强制停止(
Ctrl+C)后 JSON 行被截断- 过多的
thinking内容占用磁盘空间(是实际输出的 3-10 倍)- 由于解析错误无法恢复会话
一个用于修复和优化 Claude Code 会话 JSONL 文件的命令行工具。Claude Code 将对话历史存储在 ~/.claude/projects/ 下的 .jsonl 文件中。这些文件通常包含:
- Thinking 内容 - AI 的内部推理过程(比实际输出大 3-10 倍)
- 损坏的 JSON - 崩溃或强制停止导致的截断行
- 无效条目 - 空行、控制字符
本工具可自动修复所有这些问题。
| 项目 | 版本 |
|---|---|
| 平台 | macOS |
| 测试环境 | macOS 15.0 (24A335) |
| Python | 3.8+ |
| Claude Code | 1.0+ |
| 功能 | 描述 |
|---|---|
| 移除 thinking | 删除 thinking 和 redacted_thinking 块 |
| 自动修复 JSON | 修复截断、格式错误的 JSON 行 |
| 模糊搜索 | 按关键词查找项目 |
| 批量模式 | 使用 --all 修复所有项目 |
# 克隆
git clone https://github.com/mason0510/fix-jsonl.git
cd fix-jsonl
# 全局安装
chmod +x fix-jsonl.py
sudo ln -sf $(pwd)/fix-jsonl.py /usr/local/bin/fix-jsonl
# 或直接运行
python3 fix-jsonl.py <关键词># 按关键词修复(模糊匹配)
fix-jsonl wechat
fix-jsonl my-project
# 修复所有项目
fix-jsonl --all
# 修复指定路径
fix-jsonl /path/to/file.jsonl
fix-jsonl ~/.claude/projects/my-project
# 显示帮助
fix-jsonl| 维度 | 评分 |
|---|---|
| 功能完整性 | 85/100 |
| 实用价值 | 95/100 |
为什么实用价值 95/100?
- Claude 的 thinking 过程通常比实际输出长 3-10 倍
- 移除后可显著节省磁盘空间
- 自动修复可防止下游工具的解析错误
-
--dry-run预览模式 -
--backup创建.bak备份文件 -
--compress输出为.gz压缩文件 -
--keep-thinking仅修复格式不删除 thinking -
--all模式并行处理
このツールは anthropics/claude-code#10199 で報告された問題を修正します:
セッション JSONL ファイルの破損または肥大化
- クラッシュや強制終了(
Ctrl+C)後の JSON 行の切り詰め- 過剰な
thinkingコンテンツによるディスク容量の消費(実際の出力の 3-10 倍)- パースエラーによりセッションを再開できない
Claude Code セッション JSONL ファイルを修復・最適化するコマンドラインツールです。Claude Code は会話履歴を ~/.claude/projects/ 配下の .jsonl ファイルに保存します。これらのファイルには通常以下が含まれます:
- Thinking コンテンツ - AI の内部推論プロセス(実際の出力の 3-10 倍のサイズ)
- 破損した JSON - クラッシュや強制終了による切り詰められた行
- 無効なエントリ - 空行、制御文字
このツールはこれらすべての問題を自動的に修復します。
| 項目 | バージョン |
|---|---|
| プラットフォーム | macOS |
| テスト環境 | macOS 15.0 (24A335) |
| Python | 3.8+ |
| Claude Code | 1.0+ |
| 機能 | 説明 |
|---|---|
| thinking 削除 | thinking と redacted_thinking ブロックを削除 |
| JSON 自動修復 | 切り詰められた、不正な JSON 行を修復 |
| あいまい検索 | キーワードでプロジェクトを検索 |
| バッチモード | --all ですべてのプロジェクトを修復 |
# クローン
git clone https://github.com/mason0510/fix-jsonl.git
cd fix-jsonl
# グローバルインストール
chmod +x fix-jsonl.py
sudo ln -sf $(pwd)/fix-jsonl.py /usr/local/bin/fix-jsonl
# または直接実行
python3 fix-jsonl.py <キーワード># キーワードで修復(あいまいマッチ)
fix-jsonl wechat
fix-jsonl my-project
# すべてのプロジェクトを修復
fix-jsonl --all
# 特定のパスを修復
fix-jsonl /path/to/file.jsonl
fix-jsonl ~/.claude/projects/my-project
# ヘルプを表示
fix-jsonl| 観点 | スコア |
|---|---|
| 機能の完全性 | 85/100 |
| 実用的価値 | 95/100 |
なぜ実用的価値が 95/100 か?
- Claude の thinking プロセスは実際の出力の 3-10 倍の長さになることが多い
- 削除することでディスク容量を大幅に節約
- 自動修復により下流ツールでのパースエラーを防止
-
--dry-runプレビューモード -
--backup.bakファイル作成 -
--compress.gz出力 -
--keep-thinkingフォーマットのみ修復 -
--allモードの並列処理
- Initial public release
- Remove thinking/redacted_thinking content
- Auto-fix corrupted JSON format
- Fuzzy search project directories
- Batch mode with
--all
MIT License
Pull requests are welcome! Please open an issue first to discuss what you would like to change.
- Claude Code Issue #10199 - The issue this tool addresses