---
title: "Export ChatGPT Chat History: Export Data Steps + Markdown Script"
description: "Click Export data under Data controls, download the zip from the email, then turn conversations.json into Markdown files with a short Python script."
url: https://cdnping.org/en/blog/export-chatgpt-chat-history
language: en
published: 2026-11-11
category: "Developer tools"
tags: ["ChatGPT","data export","backup","Markdown","account security"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Export ChatGPT Chat History: Export Data Steps + Markdown Script

To export your ChatGPT chat history, use the official Export data feature. On the web, open Settings, go to Data controls, click Export data, and confirm. OpenAI then emails a download link to the address registered on your account, and you download the zip from there. The most useful file in the package is `conversations.json`, and this article includes a script that converts it to Markdown. Menu names and locations may change between versions, so go by what you actually see in your account.

## How do I run the official export?

1. Log in to ChatGPT on the web and open Settings from the profile menu.
2. Find Data controls and click Export data.
3. Confirm the export in the dialog.
4. Wait for the email. It goes to the address linked to your account, and how long it takes depends on how much history you have.
5. Click the download link in the email and save the zip. The link expires; the official documentation describes it as time-limited, so download it soon after it arrives. Check the official Help Center for the exact duration.

A few things to note:

- You need to be logged in to the same account to download, so make sure the email address can actually receive mail.
- The export covers the data in your account, not a single conversation. To save just one conversation, copy it from the chat, or use the share feature (sharing creates a public link, so think before using it).
- Temporary Chats are not saved to your history, so they cannot be exported.

## What is in the export package?

These are the files you will commonly see after unzipping. The exact list depends on the package you receive.

| File | Contents |
| --- | --- |
| `conversations.json` | Structured data for all conversations; the main file for backup and conversion |
| `chat.html` | A web version of your history you can browse directly in a browser |
| `user.json` | Basic account information |
| Other JSON files | For example feedback and shared-conversation records; these vary by version |

If you have uploaded images or files, attachment files may also appear. `chat.html` is fine for reading, but it gets huge once you have many conversations, and it is awkward to search or organize. Converting the JSON into one Markdown file per conversation is more useful.

## How do I convert conversations.json to Markdown?

`conversations.json` is a list in which each element is one conversation, with `title`, `create_time`, and `mapping`. `mapping` is a dictionary keyed by node id, and each node has `parent`, `children`, and `message`. `current_node` points to where the conversation ended. Walking back along `parent` from `current_node` gives the message chain you actually saw at the time. (If you edited a prompt or regenerated a reply, the tree has other branches; this script takes only the current branch.)

The script below uses only the standard library, and its structure is based on the commonly seen export format. If the fields in your package differ, adjust it according to the error you get.

```python
import json, re, sys, datetime
from pathlib import Path

src = Path(sys.argv[1])            # conversations.json
out = Path(sys.argv[2]); out.mkdir(exist_ok=True)

data = json.loads(src.read_text(encoding="utf-8"))

def chain(conv):
    mapping, node, items = conv["mapping"], conv.get("current_node"), []
    while node:
        n = mapping.get(node)
        if not n:
            break
        items.append(n)
        node = n.get("parent")
    return reversed(items)

def text_of(msg):
    parts = (msg.get("content") or {}).get("parts") or []
    return "\n".join(p for p in parts if isinstance(p, str)).strip()

for i, conv in enumerate(data):
    title = conv.get("title") or "untitled"
    ts = conv.get("create_time")
    day = datetime.datetime.fromtimestamp(ts).strftime("%Y-%m-%d") if ts else "unknown"
    lines = [f"# {title}", f"\n日期：{day}\n"]
    for n in chain(conv):
        m = n.get("message")
        if not m:
            continue
        role = m["author"]["role"]
        if role not in ("user", "assistant"):
            continue
        body = text_of(m)
        if body:
            lines.append(f"## {'我' if role == 'user' else 'ChatGPT'}\n\n{body}\n")
    safe = re.sub(r'[\\/:*?"<>|]', "_", title)[:60]
    (out / f"{day}-{i:04d}-{safe}.md").write_text("\n".join(lines), encoding="utf-8")
```

To run it:

```bash
python3 export_md.py ./export/conversations.json ./md
```

(The script writes the Chinese strings `日期` meaning "date" and `我` meaning "me" into the output files. Change them to English if you prefer.)

Once converted, you can search the results with any editor or with `grep`. Images, files, tool calls, and other non-text content are not strings, so the script skips them. If those matter to you, keep the original zip.

## How often should I back up?

There is no fixed answer; it depends on how much you rely on these records:

- If they hold work notes, code solutions, or prompt templates, export monthly or at the end of each project.
- If you only ask the occasional question, once a quarter is enough.
- Always export before deleting your account. Whether anything can be recovered after deletion is up to OpenAI's official policy, so exporting first is the safer course. See [How to delete your ChatGPT account: what to know before you do](/en/blog/delete-chatgpt-account-steps).
- The export contains all of your conversations, so treat it as sensitive data. Don't leave it in a public cloud-drive folder or a code repository.

## Why back up ahead of time?

An account can become unreachable because it was hacked, restricted, or because of your own mistake. Exporting requires logging in, so once the account won't open, it is too late. Some common situations and related guides:

- You suspect your account was hacked: [What to do if your ChatGPT account is hacked: signs and recovery steps](/en/blog/chatgpt-account-hacked-what-to-do).
- You want to lower the risk of a takeover: [How to turn on two-factor authentication in ChatGPT: MFA setup, recovery codes, and changing phones](/en/blog/chatgpt-two-factor-authentication-setup).
- Your account is restricted and you need the proper appeal route: [How to write a ChatGPT account appeal: where to submit, what to prepare, how long it takes](/en/blog/chatgpt-account-appeal-process-guide).
- You want a systematic self-check of your usage habits: [A checklist for avoiding restrictions on ChatGPT and Claude accounts, based on the official terms](/en/blog/beginner-ai-account-safety-checklist).

If your account is restricted, follow OpenAI's terms of service and supported-regions policy, and handle it through the official appeal channel. Regular backups keep the damage to a minimum.

## What if I only want to use the API or coding tools long term?

Chat history lives mainly in the web app. If your daily work is writing code in command-line tools such as Codex or Claude Code, whether history is saved and where it is stored depends on each tool's official documentation. It is generally not covered by the ChatGPT web export.

For readers who mostly use tools and don't really need a ChatGPT web subscription, there is AGI Plan. AGI Plan is a commercial partner of cdnping. It is a monthly-subscription, multi-provider LLM aggregation gateway that takes payment in RMB (Chinese yuan) and does not require an overseas credit card. One subscription can switch between several capability groups, and tools such as Claude Code and Codex only need a single endpoint URL changed. Some models are marked as available only outside mainland China; see the [models page](https://agiplan.dev/models) for specifics. The site also states plainly that it is not an officially authorized channel. For setup steps, see the [AGI Plan quick start](https://agiplan.dev/startup).

## What can I do after exporting?

- If an export fails or the email never arrives, first check [/en/down/chatgpt](/en/down/chatgpt) and [/en/status/openai](/en/status/openai) to see whether the service has an outage. Then check your spam folder and retry after a while.
- Next step: run an export right now, put the zip on an offline drive or in an encrypted folder, convert it to Markdown with the script above, and set a calendar reminder for your next backup.
