xdaicode

jsonl-converter

0
0
# Install this skill:
npx skills add xdaicode/skills

Or install specific skill: npx add-skill https://github.com/xdaicode/skills

# Description

Convert Claude AI JSONL session logs to readable Markdown documents. Use when you need to extract, read, or share Claude conversation history from .jsonl files.

# SKILL.md


name: jsonl-converter
description: Convert Claude AI JSONL session logs to readable Markdown documents. Use when you need to extract, read, or share Claude conversation history from .jsonl files.


JSONL 对话记录转换器

将 Claude 的 JSONL 格式对话记录转换为可读性 Markdown 文档。

使用场景

当你有一个 Claude AI Agent 的会话日志文件(.jsonl 格式),需要将其转换为易于阅读和分享的 Markdown 文档时使用此技能。

输入要求

  • 一个 .jsonl 格式的 Claude 对话记录文件
  • 文件包含 JSON 格式的对话消息,每行一个 JSON 对象

功能特性

  1. 提取完整对话内容:解析所有用户和助手的消息
  2. 格式化输出:将紧凑的 JSON 转换为易读的 Markdown 格式
  3. 保留关键信息
  4. 时间戳
  5. 消息类型(用户/助手)
  6. 完整的文本内容
  7. 工具调用信息(简化显示)
  8. 智能截断:对超长消息进行适当截断,保持文档可读性
  9. UTF-8 编码支持:正确处理中文和特殊字符

输出

生成一个 .md 文档,包含:
- 会话元信息(Session ID、Agent 信息、消息总数)
- 按时间顺序排列的所有对话
- 清晰的标题和分隔线
- 可点击的文件链接(在支持的编辑器中)

使用方法

提供 JSONL 文件路径,例如:

请将 d:/AI/agent-xxx.jsonl 转换为可读文档

技术实现

使用 Python 解析 JSONL 文件:
- 逐行读取 JSON 对象
- 提取 timestamp、type、message 字段
- 处理嵌套的 content 结构(text、tool_use、tool_result)
- 格式化为 Markdown 并输出到新文件

示例

输入:

d:/AI/agent-aa4105a.jsonl

输出:

d:/AI/agent-aa4105a_readable.md

生成的文档结构:

# AI Agent Session Log

**Session ID**: aa4105a
**Agent Slug**: optimized-gathering-rocket
**Total Messages**: 106

---

## [1] USER
**Time**: 2026-01-18 10:06:28

**Content**:
请详细探索 Yoshop 项目的运行环境要求...

---

## [2] ASSISTANT
**Time**: 2026-01-18 10:06:30

**Content**:
我将详细探索 Yoshop 项目的运行环境要求...

# README.md

# Claude JSONL to Markdown Converter

License: MIT
Python 3.7+
Claude Skill
Code style: black

Convert Claude AI Agent JSONL session logs into readable Markdown documents

✨ Features

  • 📖 Extract Complete Conversations - Parse and format all user and assistant messages
  • 🎨 Clean Markdown Output - Well-structured, easy to read documents
  • 🌍 Full UTF-8 Support - Handles Chinese characters, emojis, and special symbols
  • 🔧 Smart Content Filtering - Skip tool call noise, keep valuable content
  • 🚀 Cross-Platform - Works on Windows, macOS, and Linux
  • Zero Dependencies - Uses only Python standard library
  • 🎯 Multiple Use Modes - CLI tool or Claude Skill

📦 Installation

Manual Install

Clone to your Claude skills directory:

cd ~/.claude/skills
git clone https://github.com/xdaicode/skills.git jsonl-converter

Then restart Claude Code and use:

Please convert d:/AI/session.jsonl to a readable document

📖 See: INSTALLATION_GUIDE.md for detailed installation guide

Option 2: Direct Download

# Clone the repository
git clone https://github.com/xdaicode/skills.git
cd skills

# Run directly
python jsonl_converter.py session.jsonl

Option 3: Install as Package

# From local directory
cd skills
pip install -e .

# Or install directly from GitHub
pip install git+https://github.com/xdaicode/skills.git

Note: After installation, you can use python -m jsonl_converter instead of the full path.

🚀 Usage

# Basic conversion
python jsonl_converter.py session.jsonl

# Specify output file
python jsonl_converter.py input.jsonl output.md

This creates session_readable.md in the same directory.

Method 2: Using Python Module (After Installation)

# Convert using Python module
python -m jsonl_converter session.jsonl

# With custom output
python -m jsonl_converter input.jsonl output.md

Method 3: In Claude Code

Simply tell Claude:

Please convert d:/AI/agent-session.jsonl to a readable document

Claude will automatically use the skill to perform the conversion.

📖 Example

Input: session.jsonl

{"type":"user","message":{"role":"user","content":"Hello, Claude!"},"timestamp":"2026-01-18T10:00:00Z"}
{"type":"assistant","message":{"role":"assistant","content":"Hello! How can I help you today?"},"timestamp":"2026-01-18T10:00:05Z"}
{"type":"user","message":{"role":"user","content":"Can you explain Yoshop configuration?"},"timestamp":"2026-01-18T10:00:10Z"}
{"type":"assistant","message":{"role":"assistant","content":"Of course! Yoshop requires..."},"timestamp":"2026-01-18T10:00:15Z"}

Output: session_readable.md

# AI Agent Session Log

**Session ID**: abc123
**Agent Slug**: my-agent
**Total Messages**: 4

---

## [1] USER
**Time**: 2026-01-18 10:00:00

**Content**:
Hello, Claude!

---

## [2] ASSISTANT
**Time**: 2026-01-18 10:00:05

**Content**:
Hello! How can I help you today?

---

## [3] USER
**Time**: 2026-01-18 10:00:10

**Content**:
Can you explain Yoshop configuration?

---

## [4] ASSISTANT
**Time**: 2026-01-18 10:00:15

**Content**:
Of course! Yoshop requires...

---

🎯 Use Cases

📚 Review AI Agent Behavior

Debug and validate agent actions by examining complete conversation history.

📝 Extract Knowledge

Save valuable AI-generated content (tutorials, guides, explanations) from sessions.

🔍 Search Conversations

Easily search through exported Markdown to find specific discussions.

📤 Share Sessions

Export readable logs for team collaboration or documentation.

🗄️ Archive Records

Keep conversation history in version control for future reference.

🛠️ How It Works

The converter:

  1. Reads JSONL files line by line (memory efficient for large files)
  2. Parses JSON objects with Claude Agent metadata
  3. Extracts content from different message types:
  4. text - User and assistant messages
  5. tool_use - Tool invocations (simplified display)
  6. tool_result - Tool outputs (truncated if too long)
  7. Formats timestamps to human-readable format
  8. Filters noise (skips standalone tool calls)
  9. Outputs clean Markdown document

📋 Requirements

  • Python 3.7 or higher
  • No external dependencies

🧪 Testing

# Run tests (if available)
python -m pytest tests/

# Manual test
python jsonl_converter.py test_data/sample.jsonl

📂 Project Structure

claude-jsonl-converter/
├── jsonl_converter.py      # Main converter script
├── SKILL.md                 # Claude Skill definition
├── README.md                # This file
├── README_zh.md             # Chinese documentation
├── LICENSE                  # MIT License
├── setup.py                 # Package configuration
├── pyproject.toml          # Modern Python config
└── .gitignore              # Git ignore rules

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for guidelines.

🐛 Reporting Issues

Found a bug? Please open an issue with:

  • Clear title and description
  • Steps to reproduce
  • Expected vs actual behavior
  • Environment (OS, Python version)
  • Sample JSONL file (if possible, sanitize sensitive data)

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📮 Support

🔮 Roadmap

  • [ ] Add JSON output format option
  • [ ] Add HTML output format option
  • [ ] Create web interface
  • [ ] Add conversation statistics
  • [ ] Support other AI log formats

⭐ Show Your Support

If this project helped you, please consider giving it a ⭐️!


Made with ❤️ for the Claude AI community

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.