
How to Find and Read llm CLI Chat History (Step-by-Step)
Where Simon Willison's llm CLI stores your prompts, three ways to read past conversations, and a clean markdown export workflow for long sessions.
If you use Simon Willison's llm CLI, every prompt and response you've ever run through it is sitting on your disk in a SQLite database. Most people never open it. That's a shame, because once you know where it lives you can search, re-read, and reuse months of good conversations with Claude, GPT-4, Gemini, and local models. This guide walks through the exact file path on macOS, Linux, and Windows, three ways to read the log, and how to pull the markdown into a reader so long sessions stop being painful to scroll. If you've already got hundreds of entries, jump to the export section near the end.
The short version: llm logs to logs.db by default, you can list conversations with llm logs list, and the cleanest way to read a long one is to export it to markdown and open it in a dedicated reader. The CLI stores everything in plain SQLite with no encryption, so one file holds your entire history across every model you've connected. That makes backups trivial and portability free. It also means a few minutes of setup unlocks a searchable archive of your best prompts.
Where llm stores your chat history
The llm CLI uses the standard XDG path for its data directory. On macOS the file lives at ~/Library/Application Support/io.datasette.llm/logs.db. On Linux it sits under ~/.config/io.datasette.llm/logs.db, and on Windows you'll find it at %APPDATA%\io.datasette.llm\logs.db. You can confirm the active path on your machine by running llm logs path in a terminal, which prints the resolved location. That same command is useful if you've set LLM_USER_PATH to redirect storage somewhere custom like a synced Dropbox folder. The output is a single absolute path, so you can open or explorer it directly.
The database is a plain SQLite file with two main tables, conversations and responses. Each prompt you send becomes a row with the model name, system prompt, response text, token counts, duration, and a conversation ID that groups follow-up turns. Because it's SQLite, you can open it in any viewer, query it from Python, or point datasette at it to get a browsable web UI in one command. Nothing is encrypted, so treat the file like a notebook of everything you've ever asked an AI model. A quick checksum once a month gives you confidence the file isn't silently corrupting.
Three ways to read a conversation
The built-in commands cover most daily needs. Running llm logs with no arguments dumps the last three responses as markdown to your terminal, which is handy for grabbing a snippet you generated minutes ago. For a specific session, llm logs -c shows the current conversation and llm logs --cid <id> targets any past one. If you want everything from a given model, llm logs -m claude-3.5-sonnet filters by model name, and -q "docker compose" does a full-text search across prompts and responses. The flags compose, so you can combine them to narrow results fast.
The second approach is to query the SQLite file directly for anything the CLI doesn't expose. A query like SELECT datetime(datetime_utc), model, substr(prompt, 1, 80) FROM responses ORDER BY datetime_utc DESC LIMIT 20 gives you a clean recent-activity view. This is also how you build custom reports, like counting tokens per model per month or finding every conversation that mentions a specific project. Datasette makes the same queries clickable in a browser, which is friendlier when you're exploring rather than scripting. Either way, you own the data end to end.
The third option, which most people reach for once they have real volume, is to export conversations to markdown files and read them in a reader built for long AI output. The llm logs --cid <id> --json flag returns structured data you can pipe through a short script to produce clean per-session markdown. From there you want something that handles code blocks, math, and Mermaid diagrams gracefully. Our guide to the best markdown reader for AI content covers what to look for, and there's a dedicated walkthrough on reading AI coding agent transcripts if your logs are mostly code sessions. The export route pays for itself the first time you want to re-read a session on a tablet.
A clean export workflow
Here's a workflow that scales once you have a few hundred conversations. The idea is one markdown file per conversation, grouped by date, with enough frontmatter that a reader can filter and sort them. Keep the exports in a dedicated folder so your backup tool treats them as a single corpus. Review the folder monthly and delete throwaway sessions so the archive stays signal-dense.
- Run
llm logs list --jsonto get every conversation ID with its first prompt as a label. - Loop through the IDs and call
llm logs --cid <id> --json, piping output to a formatter that writesconversations/<date>-<slug>.md. - Add YAML frontmatter with model, token count, and tags so your reader can group sessions sensibly.
- Open the folder in a reader that renders math, code, and diagrams without reflowing on every scroll.
The reason this matters is that llm conversations get long. A single debugging session with Claude can run 40 turns and 15,000 tokens, which is painful to scroll inside a terminal and worse inside a web UI with no outline. Reading them as proper markdown files, with a sidebar of headings and jump-to-section navigation, turns the archive into something you'll open on purpose. If you work across devices, the sync AI conversations across devices guide covers how to keep the exported folder consistent on phone and laptop. A git-synced folder is often the simplest path, with the bonus of a full version history.
Backing up and sharing selectively
One underrated benefit of a single SQLite file is that backups are trivial. Copy logs.db to any cloud storage and you have a full archive of every prompt you've run. Because the file grows slowly, even a decade of heavy use rarely exceeds a gigabyte. For sharing a single conversation with a teammate, export it to markdown rather than passing the whole database, since the database contains everything including private prompts and client work. The share AI conversation with team post walks through sanitizing exports and the redact sensitive info from AI conversations guide covers scrubbing API keys and PII before you send anything.
If you archive logs quarterly, use llm logs backup /path/to/backup.db which performs a proper SQLite backup even while the CLI is writing. A plain cp can occasionally produce a corrupted file if a write is mid-flight. Rotate the backups so you can roll back to a specific month if you ever delete something by accident. Treating the database as append-only infrastructure, rather than scratch space, pays off within the first year.
FAQ
Where is the llm CLI logs database on macOS? The file lives at ~/Library/Application Support/io.datasette.llm/logs.db by default. Run llm logs path to confirm, or if you've set LLM_USER_PATH, the output will reflect that override. The directory also holds your prompt templates and plugin configuration. If you installed llm through Homebrew the path is identical, because the CLI respects the user's data directory rather than the install location.
Can I disable logging without losing past conversations? Yes, and the command is reversible. Run llm logs off to stop recording new prompts while leaving the existing logs.db untouched and queryable with every CLI flag. Re-enable with llm logs on whenever you want to resume capture. Toggling never deletes rows, so you can pause for a sensitive client project and resume later without losing your archive.
How do I search across every past conversation? Use llm logs -q "search term" -n 50 for a quick full-text search across prompts and responses. For a browsable web interface, open logs.db in datasette and click through conversations, models, and date ranges. If you want complex filters, write a SQL query directly against the responses table and join on conversations for session metadata. Save the queries as shell aliases once you find ones you reach for often.
Why export to markdown instead of reading in the terminal? Terminals are fine for recent snippets but weak for long sessions. Markdown exports give you headings, outlines, searchable archives, and consistent code and math rendering. They also work offline on phones and tablets, which the terminal cannot match. Once you have a markdown archive, you can version it, share curated subsets, and read on any device without re-running the CLI.
Read your llm CLI exports in a proper reader
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


