
How to Find and Read Google Gemini CLI Chat History: Step-by-Step Guide
Where Gemini CLI stores sessions, how to find a specific one fast, and how to turn the raw JSON into readable markdown documents you can actually revisit.
If you use Google's Gemini CLI, the terminal tool that pipes Gemini straight into your shell, you already know the problem. The conversation scrolls past, you close the tab, and the next day you remember a brilliant debugging answer that is now trapped somewhere in a cache folder you have never opened. The CLI stores more than you think, but it does not surface any of it in a way a human can read without preparation. This guide walks through where those files live, what they contain, and how to turn them into documents you can revisit instead of regret.
Gemini CLI writes conversation state to a hidden directory on your machine the moment you run your first prompt. The format is JSON, which is great for the tool and dreadful for anyone trying to reread last Tuesday's architecture discussion. The point of this walkthrough is to get you from that raw JSON to something readable in under five minutes, without installing extra tooling you will later forget about. If you have done this exercise for other AI CLIs before, the mental model is identical, and the shell commands shown here translate directly.
Where Gemini CLI Stores Your Chat History
On macOS and Linux, Gemini CLI keeps session files in ~/.config/gemini-cli/sessions/ by default. On Windows the path is %APPDATA%\gemini-cli\sessions\, which Explorer hides unless you type the path into the address bar. Each session is a single JSON file named with a timestamp and a short session ID, so a week of casual use leaves you with somewhere between twenty and fifty files. Inside each file you will find an array of message objects with role, content, timestamp, and often a tool_calls block when the model invoked a shell command on your behalf.
The field you care about most is content, which holds the markdown the model produced during the turn. That markdown contains fenced code blocks, headings, inline math on occasion, and the kind of long numbered lists Gemini likes to generate when you ask it to plan something. All of that structure survives the JSON wrapper intact, which is why the extraction step below is so quick. The same shape applies if you have ever looked at a Claude Code chat history file or an OpenAI Codex CLI transcript.
How to Find a Specific Session Fast
Timestamp filenames are useful once you know roughly when the conversation happened. Run ls -lt ~/.config/gemini-cli/sessions/ | head -20 to see the twenty most recent sessions in reverse order. If you remember a keyword from the conversation, grep -l "your_keyword" ~/.config/gemini-cli/sessions/*.json returns the file paths that contain it, and you can pipe that into your reader of choice. For deeper searches across months of history, treat the sessions folder like a tiny personal corpus and build a quick index, which is covered in the search-saved-ai-conversations guide.
A quick tip: Gemini CLI does not purge old sessions automatically, so the folder grows forever unless you prune it. Keep anything that contains real insight, archive the rest to a dated backup folder, and your grep queries will stay fast. This is also when most people discover that the folder is already closing in on a gigabyte, which happens faster than you would expect. Build the pruning habit early and the rest of this workflow stays painless.
Turning the JSON Into a Readable Document
The simplest path uses jq and a one-liner. Run jq -r '.messages[] | "## " + .role + "\n\n" + .content + "\n"' session_20261013.json > session_20261013.md and you now have a plain markdown file. The output already has H2 headings for each turn, so any decent reader renders it as a proper document with navigable structure. Open that file in Prism MD and you get real typography, syntax-highlighted code blocks, rendered Mermaid diagrams if Gemini drew any, and proper KaTeX for math expressions. The whole conversion runs in milliseconds even on a laptop that is otherwise choking on a Chrome tab.
If you want the whole folder converted at once, a small shell loop handles it. The three steps below give you a mirror of your session history as markdown files, ready to sync wherever you want to read them. Keep the loop in a dotfile so you can rerun it after every heavy Gemini session without thinking. Pair it with a weekly cron job and your reader library stays fresh with zero manual work. The hardest part of the whole setup is remembering the folder exists at all.
for f in *.json; do jq -r '.messages[] | "## " + .role + "\n\n" + .content + "\n"' "$f" > "${f%.json}.md"; done- Move the
.mdfiles into a dedicated Prism MD library folder on disk. - Sync that folder to iCloud, Dropbox, or Google Drive so the reader on your phone picks it up without extra setup.
Prism MD was built for exactly this flow. It reads markdown directly, renders math and diagrams without a plugin dance, and works offline once the files land on the device. If your transcripts also contain shell output from Gemini's tool-use mode, the same reader handles those blocks cleanly without the mangled wrapping you get in Notion or a browser preview. The result feels like reading an article rather than squinting at a log file, which is the whole point of this exercise.
Why the Default View Fails You
The terminal is a brilliant place to generate answers and a hostile place to review them. Scrollback truncates, your font never had typographic ambitions, and the line length is dictated by whatever window size you grabbed when you started the session. None of that is Gemini's fault, but it means every conversation you have in the CLI quietly loses value the moment you move on to the next prompt. Treating sessions as documents, not ephemeral logs, is the only habit that fixes this permanently.
There is also a privacy angle worth naming. Those JSON files sit in plain text on your disk, which means they are visible to any process running as your user account. If a conversation contains API keys, client names, or production hostnames, encrypt the folder with something like age or move it to a VeraCrypt volume before you forget. The team-sharing variant of this problem is covered in detail in how to share an AI conversation with your team, and the same precautions apply before you push anything to a shared drive.
Frequently Asked Questions
Does Gemini CLI sync sessions to Google's cloud? No, not by default. The tool keeps sessions local, and only the active prompt plus a configurable amount of prior context is sent to the API during each turn. Older sessions remain on your machine until you delete them yourself. If your team runs a managed Google Workspace policy, check the admin console because enterprise rollouts can override that default. For most individual users, the folder you see on disk is the full record.
Can I read Gemini CLI transcripts on my phone?
Yes, and the setup takes about three minutes. Convert the JSON to markdown with the jq command above, drop the files into a cloud folder your phone can see, and open them in Prism MD. The reader handles the long code blocks and tables that Gemini likes to produce without reflowing them into unreadable soup. The same approach works for reading other agent transcripts, including the pattern shown in the JetBrains AI assistant chat history guide.
What about tool-call blocks and shell output?
Those live inside the same content field as structured markdown with fenced code blocks around them. The jq extractor preserves them without any extra flags, so your reader shows the exact command Gemini ran and the output it saw. That trail is often more useful than the natural-language answer wrapped around it, especially when you are retracing a debugging session a week later. Keep the raw JSON too, in case you need to replay the exact tool payload for an audit.
Will the file format change in a future Gemini CLI release?
Google has rotated schema fields twice in the last year, so pin a copy of your jq script and expect to tweak a key name every few releases. The high-level structure of an array of role-tagged messages has stayed consistent across those changes. If you see a parse failure after a CLI upgrade, inspect one fresh session file, update the key names in your script, and move on. Treat the script as living code, not a one-time setup.
Make every Gemini CLI session worth rereading.
Free to start — no credit card.
Related reading
Ready to read your own AI documents?
Open ChatGPT, Claude, Gemini, or any markdown file in the reader built for the way models write.
- ✓Renders code, math & Mermaid out of the box
- ✓Works offline once you've opened a doc
- ✓Free forever for personal reading


