Skip to main content

Web IDE, visualizer & format gallery

Kaitai Struct is more than the ksc compiler. A small ecosystem of tools lets you write, test, and inspect .ksy format descriptions without setting up a local toolchain first. This page covers three of them:

  • the Web IDE at ide.kaitai.io — write and run formats entirely in the browser;
  • the visualizer (ksv and ksdump) — inspect parsed binaries from the console;
  • the format gallery at formats.kaitai.io — a library of ready-made format descriptions.
note

A .ksy format description is written in YAML. The Kaitai Struct compiler (ksc, the kaitai-struct-compiler) turns it into parser source code for one of the supported target languages: C++/STL, C#, Go, Java, JavaScript, Lua, Nim, Perl, PHP, Python, Ruby, and Rust.

The Web IDE (ide.kaitai.io)

The Web IDE is the easiest way to start: there is nothing to install. It runs the compiler and the generated parser directly in your browser, so you can edit a format and immediately see how it parses a real file.

A typical session shows several panes working together:

PaneWhat it does
Format editorEdit the .ksy YAML with syntax highlighting and live recompilation.
Hex viewerShows the bytes of the loaded binary; selecting a parsed field highlights the bytes it came from (and vice-versa).
Object treeThe parsed result as a navigable tree of fields and substructures.
Generated codeThe compiled parser, switchable between target languages (C++/STL, C#, Go, Java, JavaScript, Python, Ruby, Rust, and others).

Because parsing happens in the browser, you can toggle behaviors such as disable lazy parsing to force every field to be evaluated up front, and export results (for example, to JSON). You upload your own binary, point the editor at a format, and iterate.

tip

Two builds of the Web IDE are published. The stable build at ide.kaitai.io tracks the latest release, and a development build at ide.kaitai.io/devel/ carries the newest 0.12-SNAPSHOT features. Use the development build to try language constructs that have not shipped in a stable release yet.

The Web IDE also embeds the gallery, so you can open any published format (see below) and try it against your own data without copying files around.

The visualizer: ksv and ksdump

When you are working locally — debugging a format against a sample file, or scripting a batch dump — the kaitai-struct-visualizer provides two console tools. Both are distributed as a single Ruby gem:

gem install kaitai-struct-visualizer
ksv --version

The visualizer compiles your .ksy on the fly (so it expects ksc to be available, plus a Java runtime), then parses your binary and presents the result.

ksv — interactive console visualizer

ksv is an interactive, full-screen console UI: a hex view on one side and a navigable tree of the parsed structure on the other. Moving through the tree highlights the corresponding bytes, which makes it easy to confirm that field offsets and sizes line up with reality.

ksv <file_to_parse.bin> <format.ksy>

You can also pass an already-compiled Ruby parser (<format.rb>) instead of the .ksy.

ksdump — non-interactive dumper

ksdump parses the file and writes the whole structure to standard output in a machine-readable format. This is the tool to reach for in scripts, tests, or pipelines.

# Dump as JSON
ksdump -f json <file_to_parse.bin> <format.ksy> > output.json

The -f flag selects the output format:

-f valueOutput
yamlYAML (the default)
jsonJSON
xmlXML
info

If you would rather not install Ruby and the compiler locally, both tools ship in a Docker image. The following is an illustrative example of running them against a file in the current directory:

# ksv (interactive)
docker run --rm -it -v "$(pwd):/share" kaitai/ksv <file> <format.ksy>

# ksdump (JSON to stdout)
docker run --rm -v "$(pwd):/share" --entrypoint ksdump kaitai/ksv -f json <file> <format.ksy>

Confirm the exact image name and tags on the visualizer's repository before relying on them in a pipeline.

The format gallery is an HTML rendition of the kaitai_struct_formats repository — a curated library of .ksy descriptions for real-world binary formats. For each format, the gallery shows a block diagram, usage examples, and the parser already compiled for every supported target language, so you can drop a ready-made parser straight into your project.

The collection spans a broad range of categories, including:

CategoryExample formats
Archive fileszip, rar, gzip
Executables and byte-codeelf, microsoft_pe, java_class
Filesystemsext2, iso9660, vfat
Image filespng, jpeg, gif, bmp
Multimediawav, ogg, quicktime_mov
Networking protocolsdns_packet, tcp_segment, tls_client_hello
Serializationbson, msgpack, google_protobuf
Game data filesdoom_wad, minecraft_nbt, quake_pak
Windows-specificwindows_lnk_file, regf, windows_minidump

The repository is organized into category directories such as archive, executable, filesystem, font, game, image, media, network, serialization, and windows, among others. A cross-reference page summarizes every entry with its metadata.

note

Licensing in the gallery is per-file. Each .ksy is licensed separately — check the meta/license tag and the comments inside the individual file before reusing it. The Kaitai team claims no copyright over contributors' descriptions.

How the pieces fit together

A common workflow ties all three tools together:

  1. Browse the gallery to see whether a format already exists.
  2. If it does, grab the .ksy (or the pre-compiled parser) and use it directly.
  3. If it does not, draft a new format in the Web IDE, testing it live against a sample file.
  4. Once it works in the browser, run ksv locally for deeper debugging or ksdump to produce machine-readable output for tests and tooling.
  5. Compile the finished .ksy with ksc into your application's target language.

Sources