Export, inspect, and share local Codex sessions as Markdown, HTML, or portable bundles.
codex-session-exporter 是一个用来导出、查看、迁移本地 Codex 会话的工具,支持:
- 导出 Markdown 文档,方便离线阅读
- 导出单文件 HTML,方便分享和归档
- 导出 bundle,把会话迁移到另一个 Codex 客户端
- 导入 bundle,恢复会话原始 JSONL 和线程元数据
当前可直接使用的方式:在线安装:
curl -fsSL https://raw.githubusercontent.com/linfanxxxx/codex-session-exporter/main/scripts/install-from-github.sh | bash在线安装并顺手安装 skill:
curl -fsSL https://raw.githubusercontent.com/linfanxxxx/codex-session-exporter/main/scripts/install-from-github.sh | bash -s -- --with-skill如果后续发布到 npm,也可以这样安装:
npm install -g codex-session-exporter
codex-session-exporter install skill先安装本地 CLI 命令:
./scripts/install-cli.sh列出最近会话:
codex-session-exporter list --limit 10导出 Markdown:
codex-session-exporter export md <session-id> --output ./exports/session.md导出 HTML:
codex-session-exporter export html <session-id> --output ./exports/session.html导出 bundle:
codex-session-exporter export bundle <session-id> --output ./exports/session.codex-session完整中文说明见:README.zh-CN.md
codex-session-exporter is a standalone CLI for working with locally stored Codex sessions. It can:
- list and inspect sessions from a local Codex home
- export readable Markdown transcripts
- export single-file HTML transcripts for offline viewing
- export portable bundles for client-to-client transfer
- import those bundles back into another local Codex home
It is designed around the local storage shape used by current Codex Desktop / CLI installs:
~/.codex/sessions/**/*.jsonl~/.codex/session_index.jsonl~/.codex/state_5.sqlite
Available now: install directly from GitHub:
curl -fsSL https://raw.githubusercontent.com/linfanxxxx/codex-session-exporter/main/scripts/install-from-github.sh | bashInstall from GitHub and also install the bundled skill:
curl -fsSL https://raw.githubusercontent.com/linfanxxxx/codex-session-exporter/main/scripts/install-from-github.sh | bash -s -- --with-skillIf you publish the package to npm later, you can also install it like this:
npm install -g codex-session-exporter
codex-session-exporter install skillInstall the local CLI command:
./scripts/install-cli.shList recent sessions:
codex-session-exporter list --limit 10Export one session to Markdown:
codex-session-exporter export md <session-id> --output ./exports/session.mdExport one session to HTML:
codex-session-exporter export html <session-id> --output ./exports/session.htmlExport one session as a portable bundle:
codex-session-exporter export bundle <session-id> --output ./exports/session.codex-sessionImport a bundle into another Codex home:
codex-session-exporter import bundle ./exports/session.codex-session --codex-home ~/.codexCodex currently stores sessions locally, but there is no built-in public workflow for:
- moving a session to another Codex client
- exporting a readable archive for offline review
- preserving the raw session JSONL together with thread metadata
This tool fills that gap while keeping the export format transparent and file-based.
- A reachable
Node 22+runtime for the actual CLI - Or
Node 18+for the launcher, as long as it can discover aNode 22+binary - A local Codex home, defaulting to
~/.codex
The launcher at bin/codex-session-exporter.mjs can search for Node 22+ in:
- the current
node CODEX_SESSION_EXPORTER_NODE- the legacy compatibility variable
CODEX_SESSION_PORTABILITY_NODE NVM_BIN/nodePATHentries fornode,node22, andnodejs~/.nvm/versions/node/*/bin/node
List recent sessions:
codex-session-exporter list --limit 20Inspect one session:
codex-session-exporter inspect 019d0a15-0c56-7b61-86ed-5b1f41c263cfExport Markdown:
codex-session-exporter export md 019d0a15-0c56-7b61-86ed-5b1f41c263cf --output ./exports/session.mdExport HTML:
codex-session-exporter export html 019d0a15-0c56-7b61-86ed-5b1f41c263cf --output ./exports/session.htmlExport a portable bundle:
codex-session-exporter export bundle 019d0a15-0c56-7b61-86ed-5b1f41c263cf --output ./exports/session.codex-sessionImport and rewrite the working directory:
codex-session-exporter import bundle ./exports/session.codex-session --codex-home ~/.codex --target-cwd /new/workspaceImport and rewrite a shared root prefix:
codex-session-exporter import bundle ./exports/session.codex-session --codex-home ~/.codex --cwd-map /old/root=/new/rootIf you do not want to install the CLI into PATH, you can still run the repo-local launcher directly:
./bin/codex-session-exporter.mjs list --limit 10This repo also includes an optional Codex skill at skills/codex-session-exporter.
Install it into the local Codex skills directory:
codex-session-exporter install skillIf you are running from a local clone without installing the CLI into PATH, you can still use:
./scripts/install-skill.shThe skill installer copies the bundled skill into ~/.codex/skills/codex-session-exporter by default and records the installed package or repo path so Codex can invoke the CLI later.
For direct online installation, install-from-github.sh --with-skill downloads the repo into a local install directory and then runs both the CLI installer and the skill installer.
- The legacy command name
codex-session-portabilityis still exposed as a compatibility alias. - The readable exports keep only user and assistant messages.
- Raw tool calls and raw tool outputs remain available in bundle exports under
raw/session.jsonl. - The import/export flow depends on the current local Codex storage layout and may need updates if Codex changes its schema later.
session.codex-session/
manifest.json
transcript.md
transcript.html
raw/
session.jsonl
thread.json
thread-dynamic-tools.json
index-record.json
codex-session-exporter/
bin/
scripts/
skills/
src/
LICENSE
README.md
README.zh-CN.md
package.json