A JavaScript tool that exports Claude.ai conversations with perfect markdown fidelity by leveraging Claude's native copy functionality. Get complete conversations with both human and AI messages including tables, complex formatting, and all elements that Claude supports.
- π― Perfect Markdown Fidelity - Uses Claude's copy function for exact output
- π Complete Element Support - Tables, math, complex formatting, everything
- π Smart Filename Generation - Uses actual conversation title
- π§ Future-Proof - Automatically supports new Claude markdown features
- π Real-Time Status - Visual progress indicator during export
- π‘οΈ Robust Error Handling - Comprehensive error detection and recovery
- βοΈ Easy Maintenance - Modular selectors for UI changes
This script combines two reliable methods:
- Human Messages: Simulates clicking edit buttons to access original message content
- Claude Responses: Intercepts clipboard when copy buttons are clicked
- Perfect Output: Uses Claude's exact markdown formatting for all elements
Instead of manually parsing HTML and converting to markdown (which misses tables and complex elements), this tool uses Claude's own copy button to ensure 100% accurate markdown output. Combined with edit button simulation for human messages, you get perfect conversation exports.
β Manual HTML Parsing:
- Misses tables and complex elements
- Requires constant updates for new features
- Error-prone formatting conversion
- Maintenance nightmare
β
Copy Button Method:
- Perfect markdown fidelity
- Automatic support for ALL elements
- Future-proof against new features
- Zero formatting edge cases
- Open your conversation with Claude in your web browser.
- Open the browser's developer console:
- Chrome/Edge: Press F12 or Ctrl+Shift+J (Windows/Linux) or Cmd+Option+J (Mac)
- Firefox: Press F12 or Ctrl+Shift+K (Windows/Linux) or Cmd+Option+K (Mac)
- Safari: Enable the Develop menu in preferences, then press Cmd+Option+C
- Copy the entire script in the file
claude-chat-exporter.jsand paste it into the console. - Press Enter to run the script.
- The script will show a progress indicator and will automatically generate and download a file named
{conversation-title}.md(auto-generated withconversation-titlebeing the Claude conversation title).
Because this uses Claude's copy function, it automatically handles:
- β Tables - Perfect markdown table formatting
- β Math - LaTeX and inline math notation
- β Code blocks - With proper language detection
- β Lists - Nested lists with correct formatting
- β Links - All link types and formats
- β Formatting - Bold, italic, strikethrough, etc.
- β Blockquotes - Proper quote formatting
- β Headers - All heading levels
- β Future elements - Automatically supported
- Filename:
{conversation-title}.md(auto-generated) - Format: Perfect markdown matching Claude's copy output
- Content: Complete conversation with proper spacing
- Encoding: UTF-8 with standard line endings
The output is identical to what you get when copying Claude messages manually:
# Conversation with Claude
## Human:
Can you create a comparison table of sorting algorithms?
---
## Claude:
Here's a comprehensive comparison table of sorting algorithms:
| Algorithm | Best Case | Average Case | Worst Case | Space | Stable |
| ----------- | ---------- | ------------ | ---------- | -------- | ------ |
| Bubble Sort | O(n) | O(nΒ²) | O(nΒ²) | O(1) | Yes |
| Quick Sort | O(n log n) | O(n log n) | O(nΒ²) | O(log n) | No |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
**Key advantages:**
- Tables render perfectly β
- Math notation preserved β
- All formatting maintained β
---Adjust delays in the DELAYS object:
const DELAYS = {
hover: 50, // Time to wait for hover effects (recommended: 50ms)
edit: 150, // Time for edit interface to load (recommended: 150ms)
copy: 100, // Time between copy operations (recommended: 100ms)
};If Claude's interface changes, update the SELECTORS object:
const SELECTORS = {
userMessage: '[data-testid="user-message"]',
messageGroup: '.group',
copyButton: 'button[data-testid="action-bar-copy"]',
editButton: 'button[aria-label="Edit"]',
editTextarea: 'textarea',
conversationTitle: '[data-testid="chat-title-button"] .truncate, button[data-testid="chat-title-button"] div.truncate'
};- Execution Time: 3-8 seconds for 10-message conversations
- Success Rate: >95% with optimized delays
- Element Support: 100% (matches Claude's copy functionality)
- Memory Usage: Minimal (no large DOM processing)
- β Chrome/Chromium (recommended)
- β Firefox
- β Safari
- β Edge
Requires clipboard API support (available in all modern browsers)
The script shows real-time progress:
Extracting human messages...- Processing edit buttonsCopying Claude responses...- Clicking copy buttonsHuman: X | Claude: Y- Current countsβ Downloaded: filename.md- Success!
No Messages Captured
- Ensure conversation is fully loaded
- Check that messages are visible on screen
- Try scrolling through entire conversation first
Partial Export
- Script shows exact counts: "Human: 3 | Claude: 2"
- If mismatch, some messages may not be accessible
- Try refreshing page and running again
navigator.clipboard.writeText = function (text) {
if (interceptorActive && text && text.length > 0) {
capturedResponses.push(text); // Capture Claude's exact output
}
};// Hover -> Click Edit -> Extract -> Close
messageContainer.dispatchEvent(new MouseEvent("mouseenter"));
editButton.click();
content = textarea.value; // Original message content
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));| Method | Accuracy | Speed | Maintenance | Future-Proof |
|---|---|---|---|---|
| This Script | 100% | Fast | Low | Yes |
| Manual Copy/Paste | 100% | Very Slow | N/A | Yes |
| HTML Parsing Scripts | ~80% | Fast | High | No |
Contributions to improve the script or add new features are welcome! Please feel free to submit a pull request or open an issue to discuss potential changes.
This project benefits from:
- Selector Updates - Help maintain compatibility with UI changes
- Performance Tuning - Optimize delays for different browsers
- Error Handling - Improve robustness for edge cases
- Handling Additional Elements - Handle exporting artifacts, attachments, etc.
- Requires JavaScript - Must be enabled in browser
- Claude Web Only - Works only on claude.ai web interface
- Susceptible to DOM changes - Interface changes may require updates to CSS selectors
- Visible Messages - Only exports messages visible in DOM
- No Attachments - Cannot export uploaded files or images
- No Artifacts - Artifact content is currently skipped
- Local Processing - Everything runs in your browser
- No External Calls - Only interacts with Claude.ai DOM
- Temporary Interception - Clipboard restored after export
- No Data Storage - Messages processed and downloaded immediately
This project is open source and available under the MIT License.
This script is not officially associated with Anthropic or Claude AI. It is a community-created tool to enhance the user experience. Use it responsibly and in accordance with Anthropic's terms of service.
Perfect Exports. Every Element. Every Time.
Made for the Claude community - if this helps you, give it a β!