Skip to content

Extracts chats from a ChatGPT export file into individual markdown and formatted html files including media assets

License

Notifications You must be signed in to change notification settings

jamesmoore/chatgpt-export

Repository files navigation

ChatGPT Export²

ChatGPT Export Export

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 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.

Use cases

  • Create a readable archive - Convert your ChatGPT conversations into clean Markdown or HTML files that can be read offline, shared, or backed up.
  • Selective cleanup - Keep a local copy of the chats you want to delete from the web interface, preserving only the chats you need.
  • Knowledge‑base ingestion - Import your conversations into a wiki, knowledge base, or documentation system with minimal effort.
  • Account migration - Export all conversations before closing your ChatGPT account, so you retain a viewable copy of your data in case you need it later.

Features

  • Convert ChatGPT exports into smaller, viewable:
    • markdown files
    • html (Tailwind or Bootstrap formatted)
    • json files
  • Process multiple exports in one sweep, detecting the latest version of each conversation.
  • Include uploaded and generated image assets in the markdown.
  • 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.

Quick‑Start (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. 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
  1. Create a directory for the destination
mkdir ~/chatgpt-markdown
  1. Run the tool
./ChatGPTExport -s ~/chatgpt-export -d ~/chatgpt-markdown
  1. Open ~/chatgpt-markdown - you’ll see an html and markdown file for each conversation.

Quick-Start (Docker)

  1. 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
  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-export:latest \
  -s /source \
  -d /destination
  1. Open ~/chatgpt-markdown - you’ll see an html and markdown file for each conversation.

Quick-Start (Docker compose)

  1. 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
  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-export: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.

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
-hf
--htmlformat
Specify format for html exports (bootstrap or tailwind). tailwind
--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 of 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.

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.

Tips

  • 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.
  • 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

Extracts chats from a ChatGPT export file into individual markdown and formatted html files including media assets

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •