Registry / serialization / kaitai-struct-compiler

kaitai-struct-compiler

JSON →
library0.11.0jsnpmunverified

Kaitai Struct Compiler is a tool that generates parsers for binary data formats from a declarative YAML or JSON definition (KSY format). Current stable version is 0.11.0, released September 2025. It supports multiple target languages including C++, C#, Java, JavaScript, Python, Ruby, Rust, and Go. The compiler is part of the Kaitai Struct ecosystem, which provides a language-agnostic way to describe binary formats and then compile those descriptions into efficient, reusable parsers in various programming languages. Unlike hand-written parsers, Kaitai Struct ensures consistency across languages and reduces maintenance overhead. The compiler is distributed as a standalone JAR file, available via releases on GitHub.

npm install kaitai-struct-compiler
INSTALL
IMPORT
SIG · KAITAI-STRUCT-COMP
K
kaitai-struct-compiler
serializationjavascriptv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KaitaiStructCompiler
npm install kaitai-struct-compiler
npm install kaitai-struct-compiler --global
The compiler is a command-line tool, not a library. It is installed globally via npm for convenience.
compile
kaitai-struct-compiler -t javascript myformat.ksy
kaitai-struct-compiler --target=javascript myformat.ksy
Use -t for target language, not --target. The short flag is -t.
BinaryParser
import KaitaiStream from 'kaitai-struct/KaitaiStream';
import { KaitaiStream } from 'kaitai-struct';
KaitaiStream is a subclass exported from the npm package 'kaitai-struct' (the runtime library). The compiler generates code that uses this stream class.

Demonstrates installing the compiler, compiling a KSY file to JavaScript, and using the generated parser with the kaitai-struct runtime.

// First, install the compiler globally npm install kaitai-struct-compiler -g // Create a simple KSY file example.ksy // (YAML format describing a binary format) kaitai-struct-compiler -t javascript example.ksy // The compiler outputs example.js, which can be used with the runtime: npm install kaitai-struct // In Node.js: const KaitaiStream = require('kaitai-struct/KaitaiStream'); const Example = require('./example.js'); const buf = Buffer.from(...); // your binary data const stream = new KaitaiStream(buf); const parsed = new Example(stream); console.log(parsed);
kaitai-struct-compiler --version
Debug
Known issues
breakingv0.9 changed the default target language from Java to JavaScript.
fix
Explicitly specify -t java if you previously relied on the default.
affects: >=0.9
deprecatedThe --help flag outputs usage information; long-form options like --target are deprecated since v0.10.
fix
Use short flags (-t, -o) instead of long options.
affects: >=0.10
gotchaCompiler requires Java Runtime Environment (JRE) 8 or later to run.
fix
Install JRE 8+ and ensure java is in PATH.
affects: all
gotchaThe npm package 'kaitai-struct-compiler' is a wrapper that downloads the JAR; it does not work offline.
fix
Download the JAR directly from GitHub releases if offline.
affects: all
breakingIn v0.10, the runtime package 'kaitai-struct' changed its import path for KaitaiStream.
fix
Use require('kaitai-struct/KaitaiStream') instead of require('kaitai-struct').
affects: >=0.10
breakingv0.11 removed support for the --ksc-exception flag (no longer needed).
fix
Remove the flag from your compilation commands.
affects: >=0.11
Errors
Common errors & fixes
Error: Cannot find module 'kaitai-struct/KaitaiStream'
The runtime package 'kaitai-struct' is not installed or version mismatch.
fix
Run 'npm install kaitai-struct' to install the runtime.
Error: Could not find or load main class io.kaitai.struct.Main
Java is not installed or the JAR file is missing.
fix
Install JRE 8+ and ensure the kaitai-struct-compiler JAR is in the expected location.
kaitai-struct-compiler: command not found
The global npm installation path is not in PATH.
fix
Add npm global bin directory to PATH or reinstall with -g.
Upgrade
Version history
0.11.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
kaitai-struct-compiler — npm install kaitai-struct-compiler · libregistry