Chatgpt Conversation Extract
ASecurityTurn a ChatGPT conversation into lossless, machine-readable JSON plus Markdown for postmortem analysis - every turn, widget source and state, citation URL, asset pointer, model slug, timestamp and branch - from a public share link with no login (ChatGPT's own share JSON, fetched with curl, not scraped) or from the owner's own account in their signed-in browser, and fail loudly if anything is missing; graded against the page as Google's chrome-headless-shell renders it, images and widget SVGs ...
- 5 stars
- 0 votes
- 0 copies
- 0 views
- Added December 4, 2026
Works with
Security analysis
100/100Pro scans all 12 files and shows the line behind each finding
npx -y skills add terrylica/cc-skills --skill chatgpt-conversation-extract --agent claude-codeAre you the author of Chatgpt Conversation Extract?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/terrylica-chatgpt-conversation-extract)---
name: chatgpt-conversation-extract
description: Turn a ChatGPT conversation into lossless, machine-readable JSON plus Markdown for postmortem analysis - every turn, widget source and state, citation URL, asset pointer, model slug, timestamp and branch - from a public share link with no login (ChatGPT's own share JSON, fetched with curl, not scraped) or from the owner's own account in their signed-in browser, and fail loudly if anything is missing; graded against the page as Google's chrome-headless-shell renders it, images and widget SVGs saved with SHA-256. Every chatgpt.com/share link goes here, never Firecrawl or Jina. TRIGGERS - chatgpt share, chatgpt.com/share, backend-api/share, extract chatgpt conversation, witness render, headless shell, chatgpt postmortem, chatgpt widgets, conversations.json, chatgpt export, lossless chatgpt archive.
---
# ChatGPT conversation extract
> **Self-Evolving skill** — ChatGPT's share JSON, page and backend formats are undocumented and change without notice. If a fetch, a widget count, the completeness check or the witness starts failing, fix `scripts/chatgpt_archive/` and `references/FORMAT.md` together; see the Post-Execution Reflection at the bottom.
One normaliser, three sources, one output schema (`chatgpt-archive/1`).
| Source | When | Needs |
| --- | --- | --- |
| Mode A: public share | A `https://chatgpt.com/share/<id>` link | curl; no login (the witness: agent-browser and chrome-headless-shell) |
| Mode B: owner's account | The owner's own chats, hidden branches and tool messages included | The owner's signed-in Chrome, on the owner's Mac |
| Official export | Bulk, sanctioned | Settings, Data controls, Export data |
Run the CLI as `uv run --script "$(cc-plugin-root chatgpt-archive)/skills/chatgpt-conversation-extract/scripts/chatgpt_extract.py" <command>`. It uses only the standard library.
## Mode A: a public share link
```bash
chatgpt_extract.py share https://chatgpt.com/share/<id> --out ./cgpt-<id8>
chatgpt_extract.py witness-render https://chatgpt.com/share/<id> --out ./cgpt-<id8>
```
`share` fetches `https://chatgpt.com/backend-api/share/<id>` with plain `curl` and no login. That endpoint returns ChatGPT's own share JSON: the conversation object with `mapping`, `current_node`, `title`, `linear_conversation`, `safe_urls`, `blocked_urls`, `moderation_results` and more. The share page itself returns only a 2,938-byte shell to a non-browser client (measured 2026-12-05). `share` walks the `mapping` tree and writes:
- `conversation.json`: lossless. Every message keeps its original object verbatim in `raw`; the derived fields are views. `reconstruct_raw` rebuilds the source exactly and the file records its digest.
- `conversation.md`: readable, with widget source in fenced `dil` blocks, each citation as `title (publisher): <url>`, times in Pacific time.
- `share.json`: the share JSON exactly as fetched; `check` re-reads it. It describes the conversation, not the client that fetched it.
- `check.json`: the completeness report, and the witness counts when a witness was given.
Read a share JSON you already saved with `share --json FILE` (add the URL or id to record it). The command exits 1 when the check fails, after writing the files.
## Mode B: the owner's own conversations
Runs only on the owner's Mac, through the chrome-profiles plugin's browser-automation (the owner's signed-in Chrome via the Playwright Extension), never on a shared host. Hard rules: the access token never leaves the page and is never written to disk, a log or a transcript; no password is read or typed.
```bash
chatgpt_extract.py page-script --id <conversation-id> --out steps.json # or --all [--max N] [--files [--max-bytes N]]
bun "$(cc-plugin-root chrome-profiles)/scripts/mcp-drive.ts" ext <account-email> steps.json > run.out
chatgpt_extract.py collect run.out --out ./cgpt-raw
chatgpt_extract.py normalise ./cgpt-raw/chatgpt-export-*.json --out ./cgpt
```
`scripts/page_export.js` is the in-page function. It reads `accessToken` and `account.id` from `/api/auth/session` into its own closure, calls `GET /backend-api/conversation/{id}` (and `conversations?offset=&limit=100` for `--all`, `files/download/{id}` for `--files`), and returns counts, ids and the data to save. `scripts/capture_wrapper.js` wraps it in the one `browser_run_code_unsafe` step that `page-script` writes. It keeps every Blob the page function clicks for download, makes the click a no-op and returns the Blobs inside the step result, so nothing is downloaded: Chrome's "Ask where to save each file" setting would otherwise open a Save dialog nobody answers and lose the file, and Playwright Extension mode never fires `page.on("download")`. Never change the owner's Chrome settings for this. Only the Blobs the page function itself saved are kept; the page's own (an image, say) are dropped.
`collect` reads the saved mcp-drive output (the `"{…` result line; it needs the whole line, so do not truncate the output) and writes the export JSON to `DIR`, files to `DIR/files/`, `DIR/files/index.json` (each file's pointer or pointers, `file_id`, mime type, size, SHA-256) and `DIR/status.json`. `saved` names only what arrived; a name the page function asked for that no Blob carried is an error, and `collect` exits 1 unless everything asked for was delivered. The token is in none of it: the page function never returns it, and a test asserts the delivered text holds no `eyJhbGciOi` and no `Bearer`.
`--files` downloads both `sediment://file_…` and `file-service://file-…` pointers (base64 through the same capture, name and mime type kept) until their total would pass `--max-bytes` (default 200 MB). Everything not downloaded, over the cap or a `sandbox://` pointer, is listed with its reason. The normaliser then produces the same output as Mode A, including hidden branches and tool messages, which the share page does not show.
Status, verified live on 2026-12-04 at about 08:00 PCT (UTC−7) on the owner's Mac: the session token, `GET /backend-api/conversation/{id}` and `normalise` (COMPLETE on three real conversations of 4, 7 and 13 nodes, tool messages present) and the `files/download` call. Not verified: hidden branches and forks (none were in the sample), `--all` over a whole account, and the capture and `sediment://` paths of this version, which are tested against a mocked browser only. The response shape is in [references/FORMAT.md](./references/FORMAT.md), what the endpoints rest on in [references/EVIDENCE.md](./references/EVIDENCE.md).
## The official export
Settings, Data controls, Export data. OpenAI emails a ZIP that holds the conversations in JSON format. Feed the file, or the ZIP itself, to `normalise --mode export`. This is the sanctioned bulk path.
## The completeness check
`chatgpt_extract.py check DIR` (also run after every extraction). It recomputes the expectations from the source (re-reading `share.json` when present) and fails loudly, one `FAIL` line per gap: the archive rebuilds the source exactly, node, message, user, assistant, tool and system counts, the current path, turn count and prompts, every node on the path or in a branch, widget markers (`{@`, `<card`, `<box`, `<grid`) in the text equal those in the extracted widget sources, widget spans verbatim and parse-error free (a `<CodeBlock>` is code, not a widget: it runs to `</CodeBlock>`, or to the end of the message when the model never closes it, as ChatGPT renders it), compiled widget code present, every citation URL present, every citation title and publisher present in the Markdown (read from the source, not from the archive), the last message's text and its tail in the saved share JSON and the Markdown, the final answer of every turn in the Markdown. The Markdown keeps every message's text verbatim: inline `<Cite/>` markers are taken out of the prose and listed after it under **Inline citations** (the words before the marker, then its URLs), so the tail check compares unbroken text. A message with widgets also carries its text without fences in a collapsed block, because a widget's closing fence cannot sit inside unbroken text. Unresolved inline `<Cite/>` references are reported but do not fail, because the source holds no URL for them.
## The outside witness
The check above grades the archive against its own source. A witness grades it against the page as a browser renders it: every substantive line of it (three or more letters or digits) must appear in `conversation.md` after normalisation.
```bash
chatgpt_extract.py witness-render <url> --out DIR # DIR holding an archive: renders, then checks it
chatgpt_extract.py check DIR --witness DIR/witness.txt # or: witness DIR DIR/witness.txt
```
`witness-render` uses Google's chrome-headless-shell driven by Vercel's agent-browser, the fleet's tier 2 headless browser (lowest memory of the engines that render this page; Lightpanda gets only ChatGPT's login shell, so it is no fallback here). It never touches the desktop Chrome: it starts its own browser for the one share, with no profile, login or inherited agent-browser setting, and closes it in every case. The share page virtualises its transcript: each turn is an `<li data-message-role>` in `ol[data-conversation-transcript]`, and a user turn far from the viewport is an empty `data-transcript-spacer` placeholder that fills when scrolled into view and empties again when far away. So the command visits every turn in order, waits until it is filled, walks it through the viewport, and takes its text and images while it is filled; a turn that stays a placeholder is an error. It writes:
- `witness.txt`: the text of every transcript turn, in order. The page around the transcript (log-in prompts, sidebar, the share's date) goes to `page_chrome.txt`, not into the witness.
- `assets/`: every image, inline SVG chart and canvas the turns render (uploaded and generated images, widget SVGs, citation favicons), one file per distinct source, and `assets/manifest.json` with each file's SHA-256, bytes, mime type, kind and the turns that show it. An asset that cannot be saved is listed under `failures` and the command exits 1.
- `render.json`: the turns (role, message id, characters, images), the engine, the time taken and the witness digest. When DIR holds an archive, every visible prompt on the current path must have been rendered and every rendered turn must be a message of the archive.
On a Linux host where AppArmor stops Chrome's sandbox (`/proc/sys/kernel/apparmor_restrict_unprivileged_userns` is 1, Ubuntu 24.04 and later), the command runs chrome-headless-shell with `--no-sandbox`, and only for a `https://chatgpt.com/share/<id>` URL: the code refuses `--no-sandbox` for any other URL. `--sandbox` keeps the sandbox anyway; `--no-sandbox` asks for it explicitly. The binary is found at `--headless-shell`, `$CHATGPT_ARCHIVE_HEADLESS_SHELL`, the fleet path `~/.local/share/browser-stack/chrome-headless-shell/chrome-headless-shell`, then `PATH`.
The witness is read as text; it is never trusted over the archive. A line counts as found when its folded form is a substring of the folded Markdown, so a very short line is weak evidence and a long line is strong evidence; the check is a net for lost paragraphs, not a proof of order.
Normalisation drops markdown syntax, link targets, images, `[cite: ...]` markers, escapes, list markers, zero-width characters and case, and nothing else. A line still missing is a residual. It is accepted only by one of these rules, in this order, each tested, each counted in `check.json` under `witness.explained_by_rule`:
| Rule | Artifact it explains | What it verifies before accepting |
| --- | --- | --- |
| `svg_data_uri` | `` a widget drew | the Markdown holds an `<svg` source; each text node of the image is in the Markdown or is a computed axis label (a number, sign, unit); text beside the image is in the Markdown |
| `katex_triple` | MathML, LaTeX annotation and glyphs run together | the line is, or contains, one of the archive's own LaTeX lines, and every word it adds is one the archive has |
| `katex_inline_triple` | a variable printed as `aaa`, `XXX` or `μ\muμ` | collapsing it gives a line that is in the Markdown |
| `list_number` | `1. ` the renderer puts before a prompt | the line without the number is in the Markdown |
| `widget_caption` | `{s.n.toLocaleString()} candidate strategies` shown as `1,000 candidate strategies` | the caption's literal parts are at least three letters, and the shown value is in the same widget's source |
| `widget_computed_value` | `{mu.toFixed(2)}%` shown as `0.10%` | the literal part is in the source, every name in the expression is declared by the widget, the number has the `toFixed` shape. The value is not recomputed: that needs the widget's runtime |
| `widget_control_labels` | `Random samplingAdaptive sampling` | the line is consecutive option labels of one control |
| `katex_rendered` | a formula as its visible glyphs alone (`=SHA256(JCS(event))`, `p(V,S,R∣X)`, `μ = expected directional return`) | without spaces, the line is part of what one of the archive's LaTeX lines, or one display block row by row, renders to (text wrappers unwrapped, named symbols as glyphs); at least 6 characters, or 4 with a glyph only math produces (U+2212, U+2223) |
| `dil_link_title` | `<Link url=... title="Spec Kit"/>` shown as `Spec Kit` with a no-break space | the line holds a Link title of the archive and, spaces aside, is in the Markdown with each Link replaced by its title |
| `link_nbsp` | `Efficient Progressive Sampling\u00a0.`: a Markdown link padded with a no-break space before punctuation | the text before each such space ends a link's text in the Markdown, and without them the line is in the Markdown |
| `word_joiner` | `AGENTS.md` followed by U+2060 WORD JOINER (a file link's icon) | without it the line is in the Markdown |
| `widget_table_row` | `GUI⇥Reserve material action`: a widget `<table-row>` as tab-joined cells | the cells equal one row of one widget source |
| `widget_option_label` | `Authoritative state-changing commands only (recommended)` | the label is one `["key","label"]` option of a widget that appends `" (recommended)"`, and `key` is that question's `rec` |
| `widget_count_caption` | `{Object.keys(a).length} of {qs.length} questions answered` shown as `6 of 6 questions answered` | every expression is a `.length` of a name the widget declares, each value a whole number; a literal array must hold exactly that many elements, and a key count may not exceed it |
| `widget_text_value` | `**${price.toFixed(2)}/kg**` shown as `$12.00/kg`, in a bare text line or with a literal the normal form changes | the literal parts frame the value in the normal form; the one expression's names are declared; the number has the `toFixed` shape. Not recomputed |
| `ui_chrome` | "View sources", "Worked for 27s", "No internet•This may take a while...", the logged-out login dialog | the whole line matches one named pattern in `witness.py` |
The first seven rules were written for a Markdown witness (2026-12-03); the next eight for the headless-shell render (2026-12-05). Everything else is listed verbatim as `UNEXPLAINED`, the check exits 1, and `check.json` carries the list. Do not widen a rule to make a share pass: add a new named rule with its own test, or fix the archive. The Post-Execution Reflection below says when.
## Reading the output
- `current_path` lists node ids from the root to `current_node`. Alternate branches are in `branches` with `kind: alternate`; each node says `path_kind`, `on_current_path` and `branch_id`.
- `turns` groups the path by visible user prompt. The last node on a share can be a hidden continuation fragment of a merged answer (`merged_from` names the pieces); it is kept, not dropped.
- A message carries `role`, `create_time`, `model_slug`, `content_type`, `parts`, `text`, `widgets`, `widget_compiled_code`, `citations`, `urls`, `cite_markers`, `links`, `attachments`, `asset_pointers`, `hidden`, and `raw`.
- A widget is its state directives (`{@body const [t,setT]=DIL.useState(65)}`) plus its element block (`<card>...</card>`), verbatim, with the span in the part text.
- Format facts and the schema: [references/FORMAT.md](./references/FORMAT.md).
## Limits, stated
- A share page does not carry the owner's hidden branches or real tool outputs (tool messages read "The output of this plugin was redacted."). Use Mode B or the export for those.
- Asset pointers (`sediment://`, `file-service://`) are recorded, not downloaded, in Mode A: a share page offers no public file download. Mode B `--files` downloads them.
- ChatGPT can change the share JSON or the page at any time. `share` fails loudly on JSON that holds no conversation, and `witness-render` on a page that never settles or a turn that never fills, rather than guessing.
- A share renders no uploaded file it does not show: `assets/` holds what the page displays, while asset pointers it does not display stay pointers in the archive.
## Post-Execution Reflection
After an extraction, before closing:
1. **Did `check` print COMPLETE, and did a witness AGREE?** If not, the FAIL line names the gap: a new content type, a widget shape the scanner missed, or a changed share JSON or page. An `UNEXPLAINED` witness line is either a real loss (the archive is missing it) or a new renderer artifact (a new rule). Fix the code, add the case to `tests/test_chatgpt_archive.py`, and record the date and the change in `references/FORMAT.md`.
2. **Did a Mode B run cover something the Status paragraph lists as not verified (a fork, `--all`, the capture or `sediment://` paths)?** If so, record what the real response held in `references/FORMAT.md` and move it to verified here.
3. **Did the token or any signed URL end up in a file, log or transcript?** If so, treat it as a leak: it must not.
Only update if the issue is real and reproducible, not speculative.
Files in this skill
- SKILL.md
- references/EVIDENCE.md
- references/FORMAT.md
- scripts/chatgpt_archive/completeness.py
- scripts/chatgpt_archive/normalise.py
- scripts/chatgpt_archive/render_md.py
- scripts/chatgpt_archive/share.py
- scripts/chatgpt_archive/turbo_stream.py
- scripts/chatgpt_archive/widgets.py
- scripts/chatgpt_archive/witness.py
- scripts/chatgpt_extract.py
- scripts/page_export.js
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.