{"slug": "parsing-chatgpt-s-nested-mapping-tree-and-export-zips-in-zero-dependency-browser", "title": "Parsing ChatGPT's Nested Mapping Tree and Export ZIPs in Zero-Dependency Browser JS", "summary": "A developer published a zero-dependency browser JavaScript technique for converting ChatGPT and Claude data exports into clean Markdown, using the native DecompressionStream API to inflate ZIP archives client-side and walking the current_node parent chain to extract only the active conversation branch. The approach avoids JSZip and CDN requests, keeping the converter in a single standalone HTML file, and adds YAML frontmatter so exported threads are queryable in Obsidian Dataview or Bases. The developer also disclosed building ThreadAttic, a local-only Chrome extension for folders, pins, search and one-click Markdown export inside chatgpt.com and claude.ai.", "body_md": "If you have ever requested an official data export from ChatGPT (`Settings → Data Controls → Export`), you get a `.zip` containing a massive `conversations.json` file.\n\nTry opening it in an editor and you immediately hit two annoyances:\n\n`mapping` graph of node IDs, parent pointers, hidden system prompts, and discarded regenerations.\nHere is how to parse both ChatGPT's `.zip` / `mapping` tree and Claude's `conversations.json` into clean, Obsidian-ready Markdown **completely client-side with zero external libraries**.\n\n`conversations.json` from a `.zip` using native `DecompressionStream`\nYou do not need JSZip or a bundler to read a ZIP archive in modern browsers. A standard ZIP file ends with an End of Central Directory (`0x06054b50`) record pointing to each entry's offset, compression method (`0` = stored, `8` = deflate), and sizes.\n\nOnce you slice the compressed bytes from the local file header (`0x04034b50`), the browser's built-in `DecompressionStream('deflate-raw')` inflates it natively:\n\n``` js\nasync function inflateRaw(compressedBytes) {\n  const ds = new DecompressionStream('deflate-raw');\n  const writer = ds.writable.getWriter();\n  writer.write(compressedBytes);\n  writer.close();\n  const buf = await new Response(ds.readable).arrayBuffer();\n  return new Uint8Array(buf);\n}\n```\n\nThat keeps the entire converter in a single standalone HTML file with zero CDN requests.\n\n`current_node` branch cleanly\nA naive `Object.values(chat.mapping)` breaks conversation order and mixes in edited/regenerated branches you threw away. Instead, start from `chat.current_node` and walk `node.parent` back to the root, then reverse:\n\n``` js\nfunction extractActiveBranch(chat) {\n  const mapping = chat.mapping || {};\n  const chain = [];\n  const seen = new Set();\n  let id = chat.current_node;\n\n  while (id && mapping[id] && !seen.has(id)) {\n    seen.add(id);\n    chain.push(mapping[id]);\n    id = mapping[id].parent;\n  }\n\n  chain.reverse();\n\n  return chain\n    .map(n => n.message)\n    .filter(m => m && (m.author?.role === 'user' || m.author?.role === 'assistant'))\n    .map(m => ({\n      role: m.author.role,\n      created: m.create_time || null,\n      text: Array.isArray(m.content?.parts)\n        ? m.content.parts.filter(p => typeof p === 'string').join('\\n\\n').trim()\n        : ''\n    }))\n    .filter(m => m.text.length > 0);\n}\n```\n\nFor Claude exports (`conversations.json`), the schema is simpler: each entry has `name`, `created_at`, `updated_at`, and a flat `chat_messages` array with `sender: 'human' | 'assistant'` and `text` / `content` blocks.\n\nAdding lightweight YAML properties makes exported threads immediately queryable in Obsidian Dataview or Bases:\n\n```\n---\ntitle: \"Postgres Indexing Checklist for SaaS\"\nsource: chatgpt\ncreated: 2026-11-06\nupdated: 2026-11-06\nmessages: 3\ntags:\n  - ai-chat\n  - chatgpt\n---\n```\n\n*(Disclosure: I also build [ThreadAttic](https://lukaslabs.top/threadattic), a small local-only Chrome extension that adds folders, pins, search, saved prompts, and one-click Markdown export directly inside `chatgpt.com` and `claude.ai` — free up to 20 folders, no account. The JSON→Markdown converter above is completely free, standalone, and MIT-licensed.)*", "url": "https://wpnews.pro/news/parsing-chatgpt-s-nested-mapping-tree-and-export-zips-in-zero-dependency-browser", "canonical_source": "https://dev.to/_0db220eb1b87373faff664/parsing-chatgpts-nested-mapping-tree-and-export-zips-in-zero-dependency-browser-js-31cb", "published_at": "2026-11-26 23:36:26+00:00", "updated_at": "2026-11-26 23:44:36.764540+00:00", "lang": "en", "topics": ["developer-tools", "ai-products"], "entities": ["ChatGPT", "Claude", "Obsidian", "ThreadAttic", "OpenAI", "Anthropic"], "also_reported_by": [], "takeaway": "Walk from chat.current_node back through parent pointers and reverse the chain to extract only the active branch, and inflate ZIP entries with DecompressionStream('deflate-raw') to parse exports without JSZip.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/parsing-chatgpt-s-nested-mapping-tree-and-export-zips-in-zero-dependency-browser", "markdown": "https://wpnews.pro/news/parsing-chatgpt-s-nested-mapping-tree-and-export-zips-in-zero-dependency-browser.md", "text": "https://wpnews.pro/news/parsing-chatgpt-s-nested-mapping-tree-and-export-zips-in-zero-dependency-browser.txt", "jsonld": "https://wpnews.pro/news/parsing-chatgpt-s-nested-mapping-tree-and-export-zips-in-zero-dependency-browser.jsonld"}}