Would it be possible to add a convert function that converts an asiicast-v3 file to JSON? This would be especially useful when combining it with –rec-input to get proper machine readable command line logging that includes the output for each command issued. If the output would contain actual timestamps it would be sublime.
The asciicast format is already JSON which you can parse – asciicast v3 - asciinema docs
With a very simple jq filter which you can probably extent do match your needs, you should be able to access the data you’re looking for:
Although there are other tools, security tools, which do what you are looking for “better” if you want to know what gets executed.
Thanks for the reply. The format itself is JSON but the question was if it would be possible to have support for converting an asciicast file into a json file like asciinema convert -f txt does so that the command and output are grouped together. I guess the problem with parsing the cast file itself is to distinguish interactive commands, control sequences such as CTRL+R for reverse searches and actual commands.
If you aware of solutions that work with multiple terminals, shells, shell prompts that are able to log the command and it’s output kindly let me know.
@mir4ges So you’d like to get a series of command → output → command → output … instead of raw terminal capture, right?
Hey Yes that would actually also work for my use case I guess. The ultimate goal is to obtain output in the following JSON format.
{
“cmd”: “ls”,
“time”: “2025-08-15-11:20:23:733404000”,
“output”: “asciinema”
}
I tried to look into the topic and I am not sure if this is possible on a tty level. I am also open to any other solutions that come to mind. Was thinking if OSC 133 in combination with asciinema could actually be something to parse the asciinema logs more reliable. However, as I said I am unsure if this is something that is easier to implement directly in asciinema or a parser for the v3 format.
Injecting some special sequence into a shell prompt would allow easier parsing of commands and their outputs. As far as I know Ghostty and VS Code terminal do something like this.
