summaryrefslogtreecommitdiff
path: root/README.md
blob: d71e39489fc35f84b74d8035f8fec715fcf74414 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# Claude to Markdown

Convert your Claude.ai conversation exports into beautifully formatted Markdown files for use in Obsidian, Logseq, or any markdown-based note-taking system.

## Features

✨ **Complete Conversion**
- Converts Claude JSON exports to individual Markdown files
- Preserves full conversation history with User/Assistant structure
- Maintains conversation metadata in YAML frontmatter

📝 **Smart Formatting**
- Handles all Claude artifact types (code, React, HTML, Mermaid diagrams, SVG)
- Converts artifacts to properly syntax-highlighted code blocks
- Removes internal thinking blocks for cleaner output
- Preserves formatting and structure of conversations

🗂️ **Organized Output**
- Creates descriptive filenames: `yyyy-mm-dd-slugified-title.md`
- Includes metadata (UUID, name, summary, timestamps) in frontmatter
- Perfect for searching, filtering, and linking in your knowledge base

## Installation

1. Clone this repository:
```bash
git clone https://github.com/yuvadm/claude-to-markdown
cd claude-to-markdown
```

2. Ensure you have Python 3.6+ installed:
```bash
python --version
```

## Usage

### Basic Usage

1. Export your Claude conversations:
   - Go to [Claude.ai](https://claude.ai)
   - Navigate to Settings → Account
   - Click "Export data"
   - Download and extract the ZIP file
   - Locate `conversations.json` in the extracted files

2. Run the converter:
```bash
# Convert all conversations using defaults
python convert.py

# Specify input file and output directory
python convert.py conversations.json my_claude_notes

# Convert only first 100 conversations
python convert.py conversations.json output 100

# Show help
python convert.py --help
```

### Command Line Arguments

```
python convert.py [INPUT_FILE] [OUTPUT_DIR] [LIMIT]
```

| Argument | Description | Default |
|----------|-------------|---------|
| `INPUT_FILE` | Path to conversations.json | `conversations.json` |
| `OUTPUT_DIR` | Output directory for markdown files | `output` |
| `LIMIT` | Max number of conversations to convert | All |

### Examples

```bash
# Use all defaults (input: conversations.json, output: output/)
python convert.py

# Custom input and output paths
python convert.py ~/Downloads/conversations.json ~/Documents/claude-notes

# Process only first 50 conversations for testing
python convert.py conversations.json test_output 50

# Convert from a different location
python convert.py /path/to/claude_export.json /path/to/notes
```

3. Import to your note-taking app:
   - **Obsidian**: Copy the contents of `output/` to your vault
   - **Logseq**: Import the markdown files to your graph
   - **Notion**: Import as markdown (may need formatting adjustments)
   - **VS Code**: Open the folder directly to browse with markdown preview
   - Or use any markdown-compatible application

## Output Format

Each conversation is converted to a Markdown file with:

### Filename
```
2024-03-15-understanding-quantum-computing.md
```

### Content Structure
```markdown
---
uuid: 4dc7f4d6-7290-4b41-8bea-453c7dfeaa9f
name: Understanding Quantum Computing
summary: Discussion about quantum computing principles
created_at: 2024-03-15T10:30:00.000Z
updated_at: 2024-03-15T11:45:00.000Z
---

# Understanding Quantum Computing

## User
Can you explain quantum computing?

## Assistant
Quantum computing is a revolutionary approach to computation...
```

## Artifact Handling

The converter intelligently handles various Claude artifact types:

| Artifact Type | Converted To |
|--------------|--------------|
| `application/vnd.ant.code` | Code block with language syntax |
| `application/vnd.ant.react` | JSX code block |
| `application/vnd.ant.html` | HTML code block |
| `application/vnd.ant.mermaid` | Mermaid diagram block |
| `text/markdown` | Inline markdown |
| `image/svg+xml` | SVG code block |

## Tips for Different Platforms

### Obsidian
- Install the Mermaid plugin for diagram support
- Use Graph View to visualize conversation relationships
- Search by frontmatter fields using Dataview plugin

### Logseq
- Import files to see them in the journal view by date
- Use page properties (frontmatter) for queries
- Tag conversations for easy filtering

### VS Code
- Install a markdown preview extension
- Use the file explorer to browse by date
- Search across all files with Ctrl/Cmd+Shift+F

## Privacy & Security

- All processing happens locally on your machine
- No data is sent to external servers
- Your conversations remain private
- Consider the sensitivity of your data before sharing converted files

## Troubleshooting

**Issue**: Script says `conversations.json not found`
- **Solution**: Specify the correct path to your JSON file as the first argument

**Issue**: Some conversations are missing
- **Solution**: Conversations without content are skipped. Check the console output for the total processed

**Issue**: Special characters in filenames
- **Solution**: The script automatically sanitizes filenames for all operating systems

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Some areas for improvement:

- [ ] Add support for custom output directories
- [ ] Include conversation statistics in a summary file
- [ ] Add options for different filename formats
- [ ] Support for incremental updates
- [ ] Export to other formats (Notion, Roam, etc.)

## License

MIT License - See LICENSE file for details

## Acknowledgments

- Built for the Claude.ai community
- Inspired by the need to preserve AI conversations for future reference
- Designed to work with any markdown-based workflow

## Contact

For issues, questions, or suggestions, please open an issue on GitHub.

---

Made with ❤️ for knowledge preservation