Toggle all code blocks open/closed in Google AI Studio with lazy loading support.
See screenshots at the bottom
Adds a toolbar button to collapse or expand all code blocks instantly. Ideal for long AI conversations with lots of code snippets.
Long AI responses with multiple code blocks make conversations hard to navigate:
This script lets you control all code blocks with a single toolbar button.
| Action | Result |
|---|---|
| First Click | Activate Collapse Mode (Blue) — all current and future code blocks stay closed |
| Second Click | Switch to Expand Mode (Amber) — all current and future code blocks stay open |
| Subsequent Clicks | Toggle between Collapse/Expand modes |
MutationObserver to only process newly added code blocks (no full-page rescans).Works immediately. The toggle button appears in the top-right toolbar next to the "More options" (⋮) button.
localStorage to remember your toggle state.expand_less, expand_more) natively available in the app.