Skip to main content

Convert AI chat conversations to structured Markdown

Project description

aichat2md

Convert AI chat conversations to structured Markdown documents.

Features

  • 🌐 Extract from URLs - ChatGPT, Claude, Gemini, Doubao share links (with JS rendering via Playwright)
  • 📄 Extract from webarchive - Safari .webarchive files (offline mode)
  • 🤖 Multiple AI backends - DeepSeek, OpenAI, Groq, or any OpenAI-compatible API
  • 🌍 Bilingual support - English/Chinese prompts
  • 📝 Clean output - Knowledge-focused Markdown, not chat logs
  • Simple CLI - pip-installable, one-time setup

Quick Start

# Install
pip install aichat2md

# Configure (one-time setup)
aichat2md --setup

# Convert a ChatGPT share URL
aichat2md https://chatgpt.com/share/xxx

# Convert a webarchive file
aichat2md ~/Downloads/chat.webarchive

Supported Platforms

  • ChatGPT - chatgpt.com share links
  • Claude - claude.ai/share links
  • Gemini - gemini.google.com or g.co share links
  • Doubao (豆包) - doubao.com share links
  • Webarchive - Safari exported .webarchive files (any platform)

Usage Examples

# ChatGPT
aichat2md https://chatgpt.com/share/xxx

# Claude
aichat2md https://claude.ai/share/xxx

# Gemini (supports both long and short URLs)
aichat2md https://gemini.google.com/share/xxx
aichat2md https://g.co/gemini/share/xxx

# Doubao
aichat2md https://www.doubao.com/thread/xxx

# Webarchive file
aichat2md ~/Downloads/conversation.webarchive

Supported AI Backends

  • DeepSeek (default) - Cost-effective, Chinese service
  • OpenAI - GPT-4o-mini, GPT-4
  • Groq - Fast inference with Llama models
  • Custom - Any OpenAI-compatible API

Installation

Prerequisites

  • Python 3.8 or higher
  • Playwright (automatically installed, but requires browser setup)

Install from PyPI

pip install aichat2md

Install Playwright browsers

playwright install chromium

First-time Setup

aichat2md --setup

You'll be prompted to:

  1. Select your AI provider (DeepSeek, OpenAI, Groq, or custom)
  2. Enter your API key
  3. Choose prompt language (English or Chinese)
  4. Set output directory (default: ~/Downloads)

Usage

Basic Usage

# Convert from URL (uses configured output directory)
aichat2md https://chatgpt.com/share/xxx

# Convert from webarchive (outputs to same directory as input)
aichat2md ~/Downloads/chat.webarchive

Override Language

# Use Chinese prompts (even if English is configured)
aichat2md <url> --lang zh

# Use English prompts
aichat2md <url> --lang en

Custom Output Path

# Specify output file
aichat2md <url> -o ~/Documents/my-notes.md
aichat2md <url> --output ~/Documents/my-notes.md

Override Model

# Use a different model than configured
aichat2md <url> --model gpt-4o
aichat2md <url> --model deepseek-chat

Version Info

aichat2md --version

Configuration

Configuration is stored in ~/.config/aichat2md/config.json (cross-platform).

Example Config

{
  "api_key": "sk-your-api-key",
  "api_base_url": "https://api.deepseek.com",
  "model": "deepseek-chat",
  "language": "en",
  "output_dir": "/Users/you/Downloads",
  "max_tokens": 4000,
  "temperature": 0.7
}

Reconfigure

aichat2md --setup

Output Format

The tool converts chat conversations into structured Markdown with:

  • Front matter - Tags, date, source
  • Summary - 2-3 sentence overview
  • Key topics - Bullet point list
  • Knowledge sections - Reorganized content with logical headings
  • Code examples - Extracted code blocks with comments

Example Output

---
tags: [Python, API, Web]
date: 2026-02-02
source: https://chatgpt.com/share/xxx
---

# Building REST APIs with FastAPI

## Summary
This document covers building production-ready REST APIs using FastAPI...

## Key Topics
- API design patterns
- Request validation
- Error handling

## API Design Principles
...

## Code Examples
\```python
from fastapi import FastAPI
app = FastAPI()
...
\```

How It Works

  1. Extract - Playwright (URLs) or plistlib (webarchive) extracts raw text
  2. Structurize - AI API reorganizes into knowledge document
  3. Save - Auto-generated filename or specified path

Why Two-Stage Processing?

  • Stage 1 (Extract) - No AI tokens used, just HTML parsing
  • Stage 2 (Structurize) - AI organizes content efficiently

This saves costs and allows local caching of extracted content.

Development

Local Installation

# Clone repository
git clone https://github.com/yourusername/aichat2md.git
cd aichat2md

# Install in editable mode
pip install -e .

# Install Playwright
playwright install chromium

Run Tests

pip install pytest
pytest tests/

Build Package

pip install build
python -m build

Troubleshooting

"Configuration file not found"

Run aichat2md --setup to create configuration.

"API authentication failed"

Check your API key in ~/.config/aichat2md/config.json.

Playwright errors

Install browsers: playwright install chromium

Empty output

The conversation might be too short or the AI response failed. Check error messages.

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Submit a pull request

License

MIT License - see LICENSE file.

Links

Acknowledgments

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

aichat2md-1.3.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

aichat2md-1.3.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file aichat2md-1.3.1.tar.gz.

File metadata

  • Download URL: aichat2md-1.3.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for aichat2md-1.3.1.tar.gz
Algorithm Hash digest
SHA256 c40f2b48b8ac99f9cbe0b56658d966451b5fdb0afa8cd526996c46b68eda37a3
MD5 8539f11c89584f6d579b188cffd3fe0c
BLAKE2b-256 d93a4915c4f0a8cc876930ffaf7e4fbd94280324c31586c9af5f90cf2d0952b5

See more details on using hashes here.

File details

Details for the file aichat2md-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: aichat2md-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for aichat2md-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f2f7bcaf8aec594f64e18857c38fc03bbc4c65431daaea0a0ea79bbfb11fde51
MD5 e2c5209b22e95e2dae185ae906189eea
BLAKE2b-256 3b23b90ea9bf33ba39bf78e5fedaa4a29e618a2f93cfe70f5fcbcb6a5e32eb79

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