aichat2md
Convert AI chat conversations to structured Markdown documents.
Features
- 🌐 Extract from URLs - ChatGPT, Gemini, Doubao share links (with JS rendering via Playwright)
- 📄 Extract from local files - .webarchive, .html, .mhtml, .xhtml 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
- Gemini - gemini.google.com or g.co share links
- Doubao (豆包) - doubao.com share links
- Claude - Manual export required (see below)
- Webarchive - Safari exported .webarchive files (any platform)
- HTML Files - .html, .mhtml, .xhtml files from any browser
Usage Examples
# ChatGPT
aichat2md https://chatgpt.com/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
# HTML files (Chrome/Edge/Firefox/Safari)
aichat2md ~/Downloads/conversation.html
aichat2md ~/Downloads/conversation.mhtml
Claude Share Links
Note: Claude share links cannot be directly extracted due to Cloudflare browser detection. Please export manually:
- Open the Claude share link in your browser
- Click "Export" button (top right)
- Download as HTML or Markdown file
- Use:
aichat2md <exported-file>
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:
- Select your AI provider (DeepSeek, OpenAI, Groq, or custom)
- Enter your API key
- Choose prompt language (English or Chinese)
- 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
- Extract - Playwright (URLs) or plistlib (webarchive) extracts raw text
- Structurize - AI API reorganizes into knowledge document
- 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
Claude share link not working
Claude share links cannot be directly extracted due to Cloudflare browser detection. Please export manually:
- Open the link in your browser
- Click "Export" button (top right)
- Download as HTML or Markdown
- Use:
aichat2md <exported-file>
Empty output
The conversation might be too short or the AI response failed. Check error messages.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
License
MIT License - see LICENSE file.
Links
Acknowledgments
- Playwright - Web automation
- DeepSeek - Cost-effective AI API
- OpenAI - API compatibility standard
Metadata
Release files for aichat2md 1.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aichat2md-1.3.3.tar.gz | 19.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aichat2md-1.3.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.9 kB
Release files / aichat2md-1.3.3.tar.gz
| Download URL | aichat2md-1.3.3.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6c10bbb5724ec8b7083e96f7fd98054336fe2f8e7f20853fb828fbb24ecbd7e
|
|
BLAKE2b-256 checksum How to use checksums |
fc1b3a84e70114501aa36e85754f7c313409cacd3c830c326b0302c77f1456f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / aichat2md-1.3.3-py3-none-any.whl
| Download URL | aichat2md-1.3.3-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ccabb23eaccb18e726a810edbdb8940a4f3a8ab19fa0a4556ac8fcb55bb3f4c
|
|
BLAKE2b-256 checksum How to use checksums |
6388c6963f0f0740e57b8766024e13b6f43f024d90a29fbd94abe57d0372c299
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for aichat2md 1.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.