Skip to main content

Unofficial, unsanctioned tool to backup Claude.ai chats to local files.

Project description

claude-backup

Unofficial, unsanctioned tool to backup Claude.ai chats to local files.

uvx claude-backup

Features

claude-backup creates a full local copy of all (text) content of all branches of all chats accessible to your Claude.ai account. If you are a member of multiple "organizations", it fetches chats from all of them. We preserve all metadata on chats and their provenance, including that of their parent organization and user. We automatically rename our local copies of chats and organizations to match their current names on claude.ai.

We use an incremental sync algorithm to fetch only chats created or updated since the last backup. The fetch is done in parallel, with a typical user agent and polite rate and connection limits such that it's less traffic than manually scrolling through your chats and opening each in a new browser tab. I of course can't guarantee Big Claude won't be after you if you run this unofficial tool, but empirically they don't seem to mind.

Chats are stored as their original API JSON with nice findable names and grepable contents:

$ CLAUDE_SESSION_KEY="$(wl-paste)" uvx claude-backup
Skipping organization twilligon (c8eaca6b-eddb-4bbc-9fe3-637a0574565f) without "chat" capability
Fetching chats for organization claude@twilligon.com's Organization (9e9a56fc-6d1c-4d62-a96d-0cff3a473cf0)
30ceebd6-afcc-4796-bb77-631069cd0696    Cadre versus posse comparison
d15ac7d6-f167-43d3-afac-fcfaaafb64ec    GraphQL database backends and data sources
3e553492-89a8-45e8-b51a-b2faf9dfde64    Japanese sword quality despite poor iron sources
040343e8-db5a-4031-a21a-be237a6c661a    Balisong pin and screw maintenance
08217feb-c912-40c2-9d14-f89784d61ab5    Fixing dry falafel centers
d41bf95e-8da1-47b3-af89-aecacd7770a6    Sleep Token's artistic merits
b10e02dd-479b-4714-9d99-264d6ef4ba75    Annual human steel consumption
608f7e3d-fbcc-4891-bf67-ebc9f15c7a01    Calling payphones from mobile devices
c56ad0c5-feae-4dae-bafc-784d1f46de29    Postfix security assessment
4553fae5-61a6-40fc-b95c-36c53e706614    App store review power dynamics for major companies
0b7f4ae8-ef57-4cac-8d47-7e4c5b0e5564    Exercise timing and sleep quality
6e5385c4-6ad4-4d46-ac20-dda2105a3bea    Scented neural networks with odor emissions
$ # ...and so on... time passes... then later:
$ CLAUDE_SESSION_KEY="$(wl-paste)" uvx claude-backup
Skipping organization twilligon (c8eaca6b-eddb-4bbc-9fe3-637a0574565f) without "chat" capability
Fetching chats for organization claude@twilligon.com's Organization (9e9a56fc-6d1c-4d62-a96d-0cff3a473cf0)
4ddbcc12-5cd8-4611-813a-befdedeb4b16    Smithsonian funding and government ownership
$ tree ~/.local/share/claude-backup | head -n15
~/.local/share/claude-backup
├── account.json
├── organizations
│   └── claude@twilligon.com's_Organization-9e9a56fc-6d1c-4d62-a96d-0cff3a473cf0
│       ├── chat_conversations
│       │   ├── Free_Indirect_Discourse_Analysis-48d70be1-f23d-4757-9bcf-9d9d9711a3f6.json
│       │   ├── Fetty_Wap_name_origin-dc45880a-8c60-4366-b610-e4fe6bb9a65c.json
│       │   ├── Ryzen_Motherboard_PS_2_Port_Hunt-012583f0-83cc-4c18-8f8b-312c8cb856ac.json
│       │   ├── Tailscale_versus_wireguard_comparison-24ed7155-8d9e-410f-bf7c-cd3fb6cb4379.json
│       │   ├── Credit_card_companies_in_Europe-67ad5f75-80ba-4754-bc6c-7d21e98f948c.json
│       │   ├── OpenGL_and_Vulkan_Package_Compatibility-63859641-5ffe-459b-99b0-4759acdc8235.json
│       │   ├── Government_tech_capabilities_and_bureaucracy-1c0743f0-a124-456b-888f-d08c5b83923b.json
│       │   ├── Reverse_Engineering_Minified_JavaScript-8cf7cab1-9576-45d7-929a-ea34997b0061.json
│       │   ├── Wire_and_String_Mysteries-9ac747b7-f36e-4e86-9f24-377ab16fb5ec.json
│       │   ├── US_Senate_parliamentarian's_role_and_power-5fa34eb3-ac74-4683-8850-c90761e5f3d8.json
$ rg -0l falafel ~/.local/share/claude-backup/organizations/*/chat_conversations | xargs -0n1 basename
Fixing_dry_falafel_centers-08217feb-c912-40c2-9d14-f89784d61ab5.json
Best_falafel_restaurants_in_San_Francisco-76aa159a-e41a-4935-a2e5-d53465041e13.json
Rainy_day_food_delivery_dilemma-db4992e8-c69c-4085-a571-9a22dfff68da.json
Pita_Chip_Conversation_Search-059dca9c-bac3-4cd5-b405-34ddbbdd5fa8.json
$ rg -0l falafel ~/.local/share/claude-backup/organizations/*/chat_conversations | xargs -0 jq -r '"https://claude.ai/chat/\(.uuid)"'
https://claude.ai/chat/08217feb-c912-40c2-9d14-f89784d61ab5
https://claude.ai/chat/76aa159a-e41a-4935-a2e5-d53465041e13
https://claude.ai/chat/db4992e8-c69c-4085-a571-9a22dfff68da
https://claude.ai/chat/059dca9c-bac3-4cd5-b405-34ddbbdd5fa8

Limitations

This read-only tool is the product of reverse-engineering Claude.ai's internal API (for Good, not Evil---please don't ban me Anthropic 🙏) so I can't make any guarantees claude-backup will continue to work. That said, we make very few assumptions about the API schema, and everything works as of 2025-10-31. I'll likely update this best-effort when things break. Barring that, PRs welcome ;)

For reliable and comprehensive backups even through minor API changes, we save raw JSON responses from the API instead of normalizing them to some fixed schema. This should be a bit more resilient than forcing everything into some internal data model that could diverge from that of Claude.ai, but it means we don't download resources referenced by API objects other than what's necessary to list and fetch chat text. In practice, this preserves all textual message content and text/markdown attachments, but not images, PDFs, container uploads, "advanced research" reports, etc.

As a backup tool, we retain deleted chats (and old branches of extant chats) by default. To delete local copies, manually delete the corresponding .json from backup_dir or start from scratch by deleting backup_dir or running claude-backup --ignore-cache.

By default, claude-backup attempts to authenticate to claude.ai by extracting a session cookie from your browser. If this doesn't work (and frankly if this does work you should be sandboxing things better!) you must manually do the same. For Chrome et al., to https://claude.ai in your browser, open Developer tools with F12 or Ctrl+Shift+I, navigate to the Application tab (it may be hidden under > More tools > Application), and copy the value of the sessionKey cookie. (Firefox should be similar.) Then set the CLAUDE_SESSION_KEY environment variable to this cookie when running claude-backup:

$ CLAUDE_SESSION_KEY="sk-ant-sid01-..." claude-backup

As this tool demonstrates anyone with this cookie is authenticated as you on claude.ai so be careful and never give this to anyone or anything you do not trust! It might even be worth keeping out of history by loading it straight from your clipboard with e.g. CLAUDE_SESSION_KEY="$(wl-paste)", though the exact command varies by platform. I'm sure Claude knows which you should use ;)

As of recently(?) claude.ai is behind Cloudflare, and claude-backup can be unreliable behind a VPN. I swore to myself I was off the scrape-things-that-don't-want-to-be-scraped grind, so I recommend running claude-backup from a non-sus IP, bumping --success-delay, and lowering --connections. Any further workarounds are left as an exercise to the reader...

Install

The blazing fast and memory safe way:

$ uvx claude-backup  # installed on demand

The traditional way:

$ pip install claude-backup
$ claude-backup

The bleeding-edge way:

$ git clone https://github.com/twilligon/claude-backup
$ cd claude-backup
$ python3 -m venv venv; . venv/bin/activate  # you probably want a venv
$ pip install -e .
$ claude-backup

Usage

$ claude-backup --help
usage: claude-backup [-h] [-v] [-c CONNECTIONS] [-d DELAY] [-r RETRIES]
                     [--min-retry-delay DELAY] [--max-retry-delay DELAY]
                     [--ignore-cache]
                     [backup_dir]

Backup Claude.ai chats

positional arguments:
  backup_dir            Directory to save backups (default:
                        ~/.local/share/claude-backup)

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -c, --connections CONNECTIONS
                        Maximum concurrent connections (default: 6)
  -d, --success-delay DELAY
                        Delay after successful request in seconds (default:
                        0.25)
  -r, --retries RETRIES
                        Number of retries for API requests (default: 10)
  --min-retry-delay DELAY
                        Minimum retry delay in seconds (default: 1.0)
  --max-retry-delay DELAY
                        Maximum retry delay in seconds (default: 60.0)
  --ignore-cache        Ignore local cache and re-fetch everything from API
                        (default: False)

License

claude-backup is dedicated to the public domain where possible via CC0-1.0.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

claude_backup-0.1.11.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

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

claude_backup-0.1.11-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file claude_backup-0.1.11.tar.gz.

File metadata

  • Download URL: claude_backup-0.1.11.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_backup-0.1.11.tar.gz
Algorithm Hash digest
SHA256 c36b6ac2fca959e9bd56c98e536e74d54408a68eaa2c745a158f80b113d815fe
MD5 755a740d1f0a6aba0ef3e0c23654008b
BLAKE2b-256 3efa2d6627fa14cd08cfd171cda0f8842f4a1aeaffe6311e781ccb881ec6734d

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_backup-0.1.11.tar.gz:

Publisher: release.yml on twilligon/claude-backup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_backup-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: claude_backup-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_backup-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 c4983271e1fa48bfb2b056af764b5a82915bbd64bb713c9a9125b53471e16a45
MD5 4f02b5ee0733956f446b7194e814fcd0
BLAKE2b-256 4589a025e114fbe075c08ed6bef9bbf56f08a591cd331ab74d33c19b6943a51e

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_backup-0.1.11-py3-none-any.whl:

Publisher: release.yml on twilligon/claude-backup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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