See screenshot at the bottom
Google AI Studio | Conversation/Chat Markdown-Export/Download (XHR/DOM)
Instantly export complete Google AI Studio conversations to Markdown. Features dual extraction modes (XHR instant capture + DOM scroll-based fallback), native toolbar integration, configurable export options, collapsible thinking blocks, and seamless support for new chats and navigation.
Features
Dual Extraction Modes
- XHR Mode (Default, Recommended): Intercepts network endpoints (
ResolveDriveResource, CreatePrompt, UpdatePrompt) for instant capture directly from Google's servers. No scrolling required.
- DOM Mode (Fallback): Automatically scrolls through the conversation and extracts content from visible elements. Useful when XHR capture fails or for edge cases.
- Easy Toggle: Switch between modes via the settings panel toggle switch.
Full Conversation Lifecycle Support
- Works on existing saved chats
- Works on brand new chats (first message)
- Works when continuing conversations
- Automatically updates when switching between chats
Thinking Block Support
- Captures and exports the model's internal "thinking" or "reasoning" content
- Toggle inclusion on/off via settings
- Collapsible
<details> sections for cleaner readability (optional)
Customizable Export Settings (Right-click the button)
- Toggle User Messages
- Toggle Model Responses
- Toggle Thinking Blocks
- Toggle Collapsible Thinking (HTML details/summary)
- Switch between XHR and DOM extraction modes
- Settings persist across sessions
Additional Features
- Instant Capture: No scrolling, no waiting in XHR mode. Data captured the moment it arrives.
- Seamless SPA Navigation: Handles AI Studio's Single Page Application design flawlessly.
- Smart Timing Protection: 2-second debounce prevents data loss during new chat URL updates.
- Smart Recursive Parsing: Advanced algorithm locates chat history regardless of JSON structure changes.
- Native Toolbar Integration: Seamless download button using Material Design styling.
- Clean Markdown Output: Well-formatted
.md files ready for archiving or use with other tools.
- Keyboard Support: Press
Escape to close the settings panel.
- Silent Raw Mode Toggle: DOM mode switches to Raw Mode silently (no visible menu flash) for cleaner extraction.
Installation
Requirements
- A userscript manager browser extension:
Steps
- Install one of the userscript managers listed above.
- Click the install button for this script.
- The script will automatically activate on
https://aistudio.google.com/*.
Usage
Basic Export
- Navigate to any conversation in Google AI Studio (new or existing).
- Look for the Download Icon (green) in the top-right toolbar.
- Left-click the button to instantly download the Markdown (
.md) file.
- Switching Chats? Just click a different prompt in the sidebar. The script automatically detects the new network response and is ready to export immediately.
Customize Export Settings
- Right-click the download button.
- A settings panel appears with:
- Include User Messages: Toggle your own prompts in the export.
- Include Model Responses: Toggle AI responses in the export.
- Include Thinking: Toggle the model's reasoning/thought process (sub-option of Model Responses).
- Collapsible Thinking: Export thinking blocks as collapsible sections (sub-option of Include Thinking).
- Extraction Method Toggle: Switch between XHR (instant) and DOM (scroll-based) modes.
- Close the panel by:
- Clicking the ✕ button in the top-right corner
- Clicking outside the panel
- Pressing
Escape
- Your settings are saved automatically and persist across sessions.
When to Use DOM Mode
DOM mode is provided as a fallback for situations where XHR capture might not work:
- If XHR mode reports "No data available" but you can see the conversation
- For debugging or verification purposes
- When network interception is blocked
In DOM mode, the script will:
- Silently switch to Raw Mode (if not already)
- Scroll through the entire conversation automatically
- Extract all visible content
- Restore the original view mode
- Download the Markdown file
How It Works
XHR Mode (Default)
Unlike traditional scrapers that read text from the rendered page, this script uses a more robust approach:
- XHR Interception: Extends
XMLHttpRequest.prototype to listen for three specific endpoints:
ResolveDriveResource (loading existing chats)
CreatePrompt (creating new chats)
UpdatePrompt (continuing conversations)
- Data Capture: Google sends full conversation history as JSON. The script silently captures this data.
- Structure Normalization: Different endpoints return different JSON wrapper formats. The script normalizes them.
- Recursive Search: Scans deeply nested JSON to find dialogue turns, regardless of structure.
- Turn Classification: Analyzes each turn using array positions
[8], [16], [19] to identify user messages, model responses, and thinking blocks.
- Markdown Formatting: Converts data into clean Markdown with optional collapsible thinking blocks.
- Download: Generates a file named after the chat title and triggers browser download.
DOM Mode (Fallback)
When XHR mode isn't suitable, DOM mode provides an alternative:
- Mode Detection: Checks if page is in Raw Mode or Rendered Mode.
- Silent Raw Mode Toggle: Switches to Raw Mode without visible menu flash for cleaner extraction.
- Auto-Scroll: Scrolls through the entire conversation to load all virtualized content.
- Element Extraction: Captures text from DOM elements (
ms-chat-turn, ms-text-chunk, etc.).
- Thinking Expansion: Automatically expands collapsed thinking sections.
- Mode Restoration: Returns to original view mode after extraction.
- Markdown Generation: Same formatting as XHR mode for consistent output.
Technical Details
XHR Mode
- Transport: Captures XMLHttpRequest (XHR) responses only.
- Data Completeness: Each network response contains the full conversation state.
- Thinking Detection: Position
[19] === 1 in turn array.
- Response Detection: Position
[16] === 1 in turn array.
- Navigation Safety: 2-second timestamp buffer prevents premature data clearing.
DOM Mode
- Scroll Speed: 50ms delay between scroll steps for fast extraction.
- Raw Mode: Automatically switches for reliable text extraction.
- Silent Toggle: Menu operations executed synchronously to prevent visual flash.
- Abort Support: Click button during extraction to cancel (data discarded).
FAQ
Q: I don't see the button.
A: If you just installed the script, refresh the page once. The button appears automatically after the toolbar loads.
Q: Can I export a brand new chat I just started?
A: Yes! After the first AI response completes, the data is captured and ready to export immediately.
Q: Does this send my data anywhere?
A: No. The script runs entirely locally in your browser. It only converts the data Google already sent you into a text file.
Q: When should I use DOM mode instead of XHR mode?
A: XHR mode is recommended for most cases. Use DOM mode only if XHR reports "No data available" but you can see the conversation on screen.
Q: Why do thinking blocks appear as HTML in my Markdown viewer?
A: Collapsible sections use <details> tags, which are valid HTML inside Markdown. Most modern renderers (GitHub, Obsidian, VSCode) support them natively.
Q: Can I disable thinking blocks entirely?
A: Yes. Right-click the download button and uncheck "Include Thinking."
Q: Can I abort DOM mode extraction?
A: Yes. Click the button while extraction is in progress (it shows a red cancel icon). All captured data will be discarded.
Q: Does DOM mode work with long conversations?
A: Yes. DOM mode automatically scrolls through the entire conversation, handling lazy-loaded content. However, very long conversations may take several seconds.