Skip to content

jamesmoore/chatgpt-archive-tools

Repository files navigation

ChatGPT Archive Tools

About

ChatGPT does not offer a clean, built-in way to save or print conversations for offline or archival use. While some browser extensions exist, they may pose security risks.

This tool enables you to browse, search, extract and reformat your conversations from the official ChatGPT export ZIP file. You can export your data via ChatGPT settings - https://chatgpt.com/#settings/DataControls.

Features

  • Browse and search your ChatGPT exports in a web UI.
  • Convert ChatGPT exports into smaller, viewable markdown, html and json files
  • Process multiple exports in one sweep, detecting the latest version of each conversation.
  • Include uploaded and generated image assets in the markdown (thanks to GLightbox).
  • Transform web references into markdown footnotes.
  • Include code blocks and canvas with syntax highlighting (thanks to highlight.js).
  • Detect and render mathematical notation (thanks to mathjax)
  • Runs on Docker, Windows, Linux and MacOS.
  • Fully open source with no usage limits or monetization.

Two modes

  1. ChatGPT Archive Server - which runs a local website serving your exported chats.
  2. ChatGPT Exporter - a command line tool that can tansform your exported chats into new html and markdown files on your filesystem.

First steps

Request your export ZIP in ChatGPT settings at https://chatgpt.com/#settings/DataControls.

Unzip your ChatGPT export ZIP somewhere - Important - keep an eye out for any ZIP errors:

mkdir ~/chatgpt-export
unzip ~/Downloads/chatgpt_export.zip -d ~/chatgpt-export

ChatGPT Archive Server

The archive server hosts a web UI for browsing your exported conversations. It reads one or more source directories that contain conversations.json.

You can provide multiple sources. For bare metal, pass -s/--source multiple times (for example: -s dir1 -s dir2). For Docker, set SOURCE to a semicolon-separated list (for example: SOURCE="/source1;/source2") and mount each directory.

Archive Server - Bare metal
  1. Download the latest chatgpt-archive-server binary for your system from the Releases page and unpack it.
  2. On unix systems you may need to chmod +x it.
  3. Run the server (use -s/--source to point at your export folder):
./chatgpt-archive-server -s ~/chatgpt-export

If your filesystem is case-sensitive, use the exact project folder casing. 4. Open the URL printed in the console (typically http://localhost:5000).

Archive Server - Docker compose (Recommended)
  1. Create a docker-compose.yaml (adapt the SOURCE and volume path as needed):
services:
  chatgpt-archive-server:
    image: ghcr.io/jamesmoore/chatgpt-archive-server:main
    environment:
      SOURCE: /source
    ports:
      - "8080:8080"
    volumes:
      - ~/chatgpt-export:/source:ro
  1. Run the container:
docker compose up
  1. Open http://localhost:8080. The container listens on port 8080, so change the host port as needed. You can also run it behind a reverse proxy like Traefik, Caddy, or Nginx, in which case the port can be ignored.
Archive Server - Docker
  1. Run the container (set the SOURCE env var and mount the export folder):
docker run --rm \
  -p 8080:8080 \
  -e SOURCE=/source \
  -v ~/chatgpt-export:/source:ro \
  ghcr.io/jamesmoore/chatgpt-archive-server:main
  1. Open http://localhost:8080. The container listens on port 8080, so change the host port as needed (for example: -p 80:8080). You can also run it behind a reverse proxy like Traefik, Caddy, or Nginx.

ChatGPT Exporter

You can export from multiple sources. For bare metal, pass -s/--source multiple times (for example: -s dir1 -s dir2). For Docker, mount each source directory and pass multiple -s values (for example: -s /source1 -s /source2).

Exporter - Bare metal
  1. Download the latest binary from the Releases page and unpack it.
  2. On unix systems you may need to chmod +x it.
  3. (Optional) Add it to your PATH.
  4. Create a directory for the destination
mkdir ~/chatgpt-markdown
  1. Run the tool
./chatgpt-exporter -s ~/chatgpt-export -d ~/chatgpt-markdown
  1. Open ~/chatgpt-markdown - you’ll see an html and markdown file for each conversation.
Exporter - Docker compose
  1. Create a directory for the destination
mkdir ~/chatgpt-markdown
  1. Create a docker-compose.yaml (adapt the -v ~/chatgpt-export and -v ~/chatgpt-markdown parameters to the directories you have just created)
services:
  chatgptexport:
    command: >
      -s /source
      -d /destination
    # append any other parameters as needed
    image: ghcr.io/jamesmoore/chatgpt-exporter:latest
    volumes:
      - ~/chatgpt-export:/source:ro
      - ~/chatgpt-markdown:/destination
  1. Run the container:
docker compose run --rm chatgptexport
  1. Open ~/chatgpt-markdown - you’ll see an html and markdown file for each conversation.
Exporter - Docker
  1. Create a directory for the destination
mkdir ~/chatgpt-markdown
  1. Run the docker command (adapt the -v ~/chatgpt-export and -v ~/chatgpt-markdown parameters to the directories you have just created)
docker run --rm \
  -v ~/chatgpt-export:/source:ro \
  -v ~/chatgpt-markdown:/destination \
  ghcr.io/jamesmoore/chatgpt-exporter:latest \
  -s /source \
  -d /destination
  1. Open ~/chatgpt-markdown - you’ll see an html and markdown file for each conversation.

Exporter Complete Usage

Parameter Optional? Usage Default
-?
-h
--help
Show help and usage information
--version Show version information
-s
--source
Required The source directory/directories containing the unzipped ChatGPT exported files.
Must contain at least one conversations.json, in the folder or one of its subfolders.
You can specify a parent directory containing multiple exports.
You can also specify multiple source directories (eg, -s dir1 -s dir2)
-d
--destination
Required The directory where markdown files and assets are to be created
-e
--export
Export mode (latest or complete) see below. latest
-j
--json
Export to json files (true or false). false
-m
--markdown
Export to markdown files (true or false). true
--html Export to html files (true or false). true
--text Export to plaintext files (true or false). false
--showhidden Includes hidden content in markdown and html exports.
Enabling this will include thinking, web searches, image prompts in the export.
false
--validate Validate the json against the known and expected schema. false

How it works

The source folder must contain a file named conversations.json, which holds all your conversations in JSON format. The conversations.json can be in a subfolder, and you can have multiple subfolders (eg, one for each export if you have created many).

Each conversation is converted into one or more files in the destination folder. Depending on the parameters passed in, json, markdown and html files may be created.

The files will be named with a timestamp and the conversation title (eg, <YYYY-MM-DDTHH-MM-SS> - <chat title>.md). The timestamp is the creation date of the conversation.

For markdown and html exports, any image assets are also extracted and copied to the destination folder.

Caution

Running this on a large export may create many files. It will also overwrite any existing files with the same name. Be sure to choose choose an empty destination directory for the first run.

Export modes

There are two export modes - latest and complete. This is to handle conversations that have multiple branches. In ChatGPT If you click "Try again..." or go back and edit one of your previous messages, this causes the conversation to start a new branch. The old branch is hidden and the conversation continues on the latest branch.

latest is the recommended mode, as it will produce an export that contains the latest instance of the conversation. complete mode will include all the old hidden branches together in a single document. Because of this the conversation may not be coherent.

Asset management

Any images generated in ChatGPT that are included in the exports will be copied into the destination directory under a subdirectory named tool-assets. The corresponding path in the markdown and html will be updated to a relative path. Similarly images uploaded by the user are copied into user-assets and referenced the same way.

Note

Keep a copy of your original export ZIPs. In the future you may want to re‑run the tool to generate updated Markdown or a better format. This program may be improved with new features in the future. Someone else may write a better one.

About

Serve up your ChatGPT export file as a local website. Extract chats from a ChatGPT export file into individual markdown and formatted html files including media assets

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors