You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: opencode session export to markdown or json #9387
@paralin hey I was wondering, is the current session export to JSON somehow insufficient? I totally welcome Markdown exports for human consumption, just the JSON is already available and your PR seems to duplicate it.
If no sessionID given, a small and simple selection TUI opens.
$ opencode export --help
opencode export [sessionID]
export session data as JSON
Positionals:
sessionID session id to export [string]
Options:
-h, --help show help [boolean]
-v, --version show version number [boolean]
--print-logs print logs to stderr [boolean]
--log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]
I'm not the original creator of this, but I am also looking forward to this. For us, the markdown export is definitely more useful than the JSON because we want to make it readable for humans without going through a whole additional level of JSON->Markdown transformation.
@mrw if you need something right now, OpenCode already supports /export which does exactly the MD export of the active session - product of an earlier PR of @paralin (just found out and used today, thx!)
Thanks! We've been using that but are hoping to get this in a CLI flag so we can automate it better as part of an internal conversation sharing flow/system we're building. (I'm just sharing this to help contextualize the feedback/use case).
Hi. Not sure if this is relevant one, but wanted to share: for a relatively long session exporting via TUI ("Export session transcript", Ctrl-x x) produces truncated markdown in a way when a few initial queries from the very beginning of a session are missing. Exporting the same session from CLI to JSON works just fine with the entire history present in resulting JSON.
+1 for having a CLI option to choose format, and hopefully the above finding would save someone's time.
I just published another workaround while this is open: oc-transcript, a small CLI app that opens opencode.db read-only and prints a chronological transcript to stdout or to a file.
One caveat, and the reason I still want this feature in opencode itself: the tool reads the database directly, and the schema is apparently not a public API. Any change to it on your side can break the tool without warning. A built-in export command stays correct across such changes; an outside reader cannot.
Activity
github-actions commentedon Jan 19, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
tetipong2542 commentedon Jan 21, 2026
I Needed
paralin commentedon Jan 21, 2026
Implemented; #5426
dhruvkej9 commentedon Jan 28, 2026
@rekram1-node please merge this export is very difficult currently, also there is no way to export to JSON
Nindaleth commentedon Feb 12, 2026
@paralin hey I was wondering, is the current session export to JSON somehow insufficient? I totally welcome Markdown exports for human consumption, just the JSON is already available and your PR seems to duplicate it.
If no sessionID given, a small and simple selection TUI opens.
mrw commentedon Feb 12, 2026
I'm not the original creator of this, but I am also looking forward to this. For us, the markdown export is definitely more useful than the JSON because we want to make it readable for humans without going through a whole additional level of JSON->Markdown transformation.
Nindaleth commentedon Feb 12, 2026
@mrw if you need something right now, OpenCode already supports /export which does exactly the MD export of the active session - product of an earlier PR of @paralin (just found out and used today, thx!)
mrw commentedon Feb 12, 2026
Thanks! We've been using that but are hoping to get this in a CLI flag so we can automate it better as part of an internal conversation sharing flow/system we're building. (I'm just sharing this to help contextualize the feedback/use case).
mnickw commentedon Apr 1, 2026
It would be great to have output file path as an argument as well
mnickw commentedon Apr 1, 2026
Also would be awesome to have export to md in sdk as well
blain3white commentedon Jun 8, 2026
If you need a workaround/reference, I'm building Clean My Agent for local AI-agent session scan/backup/export, including OpenCode sessions: https://github.com/blain3white/clean-my-agent
defanator commentedon Jul 1, 2026
Hi. Not sure if this is relevant one, but wanted to share: for a relatively long session exporting via TUI ("Export session transcript", Ctrl-x x) produces truncated markdown in a way when a few initial queries from the very beginning of a session are missing. Exporting the same session from CLI to JSON works just fine with the entire history present in resulting JSON.
+1 for having a CLI option to choose format, and hopefully the above finding would save someone's time.
(Observing this with opencode 1.17.12.)
emyasnikov commentedon Jul 30, 2026
On long context and compaction the sessions are getting truncated, those why I implemented own plugin to avoid this (https://github.com/emyasnikov/opencode-session-store), but hope to see an built-in feature (#39641).
Chi-teck commentedon Aug 21, 2026
I just published another workaround while this is open: oc-transcript, a small CLI app that opens
opencode.dbread-only and prints a chronological transcript to stdout or to a file.One caveat, and the reason I still want this feature in opencode itself: the tool reads the database directly, and the schema is apparently not a public API. Any change to it on your side can break the tool without warning. A built-in export command stays correct across such changes; an outside reader cannot.
neriousy commentedon Oct 1, 2026
OpenCode v2 can export sessions:
opencode session export [session]writes the session as JSON (--sanitizeis available), andopencode session importloads it back./exportsaves the transcript as Markdown or JSON, either to the clipboard or to a file.Added in #40914 and moved under the
sessioncommand in #48055.Closing as completed. If something doesn't work on v2, please open a new issue.
LorenzoBettini commentedon Oct 15, 2026
But in the desktop app it always export as JSON; I typically prefer markdown; isn't there a way to export it as markdown in the desktop app?
Chi-teck commentedon Oct 15, 2026
@LorenzoBettini the agent conversations typically happen in markdown format. So it would be tricky to wrap markdown messages into markdown export.