OmniscioGuidesExport a Claude Code conversation
How to export a Claude Code conversation to a file
Claude Code saves every conversation locally as you work, so getting one out is a matter of picking the format you actually need: text for a person, structured JSON for a program, or the session itself for continuing work.
Claude Code saves every conversation. /export copies the open one as readable text, the transcript files sit on disk, and --output-format json gets you data for a script.
Last checked against Anthropic's Claude Code documentation on November 18, 2026. By the Omniscio team. Updated .
The /export command
Run /export at the prompt. With a filename it writes directly to that file. With no filename it opens a dialog, and you choose between copying the conversation to your clipboard and saving it to a file.
What comes out is a plain-text file with the messages and tool outputs rendered as readable text. Anthropic is careful to call this a rendered transcript for a person to read, which tells you what to expect: it is a record, not a data format.
That distinction matters when you plan to do something with the file. If you want to count turns, diff two sessions or feed the content to another program, the rendered text makes it awkward, and the JSON interfaces in the next sections are the route Anthropic points you to.
Sources: the /export entry in Commands and "Export and locate session data" in Manage sessions, read November 18, 2026.
Where the transcripts live on disk
By default Claude Code stores every conversation as JSONL at ~/.claude/projects/<project>/<session-id>.jsonl. The project folder name is your working directory path with non-alphanumeric characters replaced by -.
Each line is a JSON object: a message, a tool use or result, a record of a request sent to the model, or a metadata entry. The file is the session, so every turn is already there after the fact.
Anthropic warns against building on that format. It calls the entry format internal to Claude Code, says it changes between versions, and states that scripts parsing these files directly can break on any release.
Two settings change where the files go and how long they stay. CLAUDE_CONFIG_DIR moves storage off ~/.claude, and cleanupPeriodDays changes the 30-day retention.
Source: "Where transcripts are stored" in Manage sessions, read November 18, 2026.
Resume, continue and fork
If you want to keep working in the conversation rather than keep a copy of it, continue it instead. claude --continue reopens the most recent session in the current directory, and prints No conversation found to continue if there is none.
claude --resume opens the session picker, claude --resume <name> jumps to a named session, and /resume switches sessions from inside a running one. You can also pass the absolute path to a transcript file.
Add --fork-session to resume with a new session ID instead of reusing the original. Anthropic recommends it when you want two copies: resuming the same session in two terminals at once writes both to one transcript, and messages from one can go missing later.
One gap is worth knowing. Sessions created with claude -p do not appear in the picker or in claude --continue. You can still reach one by passing its session ID to claude --resume. The resume guide and the fork guide cover those paths in detail.
Sources: "Resume a session" and "Branch a session" in Manage sessions, and the --continue and --fork-session rows in the CLI reference, read November 18, 2026.
Getting JSON for a script
Non-interactive mode is where structured output comes from. Add -p to run without the interface, and choose an output format: text is the default, json returns one structured object, and stream-json returns newline-delimited events as they happen.
claude -p "Summarize this project" --output-format json
claude -p "Continue that review" --resume "$session_id" --output-format jsonThe JSON carries the result, the session ID, usage and cost. That is enough to capture a run's output and its identity in one call, then send a follow-up prompt to the same session later using the ID you stored.
With stream-json, the last line of the stream is a result message with the final response, cost and session metadata. You can pipe either format into jq (a command-line JSON reader), and Anthropic's own example reads .result from a resumed run.
Sources: "Get structured output" and "Continue conversations" in Run Claude Code programmatically, read November 18, 2026.
What is not an export
Checkpoints are not an export. They are automatic snapshots of Claude's file edits, they are designed for quick, session-level recovery, and Anthropic says plainly that version control is what you use for permanent history. The checkpoints guide covers rewind.
A checkpoint also restores less than people assume. A file that only a Bash command changed is not tracked and stays as it is, and the snapshots are deleted in the retention sweep, by default about 30 days after the session last saved one.
Compacting is not an export either, though it looks like one. Summarizing does not change files on disk, and the original messages stay in the session transcript, so a summary is a way of freeing context rather than a way of archiving.
Sources: "Limitations" and "Not a replacement for version control" in Checkpointing, read November 18, 2026.
Common mistakes
- Parsing the
.jsonlfiles in a script. Anthropic calls the format internal and says it changes between versions. Use--output-format jsoninstead. - Expecting a rendered export to be machine-readable. It is text laid out for a person, with tool output written out in full.
- Resuming one session in two terminals. Both write to one transcript. Add
--fork-sessionwhen you want two copies. - Looking for a
-psession in the picker. Sessions started with-pare left out of it; resume by session ID. - Treating
/rewindas a backup. It covers file edits from the session and is deleted on the same schedule as the session.
Where these answers come from
- The command, the transcript path and the resume routes: Manage sessions, read November 18, 2026.
- The
/exportentry and the/resumeentry: Commands, read the same day. - The flags, including
--fork-session,--resumeand--output-format: the CLI reference, read the same day. - JSON output, streaming and resuming a headless run: Run Claude Code programmatically, read the same day.
- Why a checkpoint is not an export: Checkpointing, read the same day.
Common questions
Where does /export save the file?
If you pass a filename, /export writes directly to that file. With no filename it opens a dialog, and you choose between copying the conversation to your clipboard and saving it to a file.
Does /export include tool calls and their output?
Yes. Anthropic describes the result as a plain-text file with messages and tool outputs rendered as readable text, which is what makes it useful as a record rather than a data format.
Can I export a conversation I have already closed?
Sessions are saved to local transcript files as you work, so a closed conversation can be reopened with claude --resume and exported from there.
How do I get a conversation as JSON instead of text?
Use a non-interactive run: claude -p with --output-format json returns a result, the session ID, usage and cost as structured JSON. stream-json gives the same as newline-delimited events.