Parse Codex jsonl with jq
12 Dec 2025 in TIL
I recently built a GitHub extension using ChatGPT Codex, and I wanted to share the prompts that I gave to Codex to build the tool.
I thought about copy/pasting it out of the VSCode UI, but figured that the data must be available somewhere. It turns out that Codex stores sessions as .jsonl files in .codex/sessions.
Looking through the session files, there's a ton of data in there around what the LLM does, but I was only interested in messages that I sent. Fortunately each user message has type: user_message.
Here's a one liner that uses jq to output all of the user messages for a given session:
bashcat .codex/sessions/2025/12/04/rollout-2025-12-04T22-06-28-019aeb67-0620-71c1-8cbb-756bc8845c6e.jsonl | \jq -r '. |select(.payload.type == "user_message") |.payload.message |split("\n## My request for Codex:\n")[1] + "\n\n--- NEW COMMAND ---\n\n"'