Kaitai project is happy to announce the first pre-release of Kaitai Struct 2.0 (see #1293), the next major version of Kaitai Struct, declarative markup language to describe various binary data structures — binary file formats, network stream packets, etc.
The basic idea of Kaitai Struct is that a particular format can be
described using Kaitai Struct language (in a .ksy file), which then
can be compiled using kaitai-struct-compiler into source files in
one of the supported programming languages. These modules will include
a generated code for a parser that can read described data structure
from a file / stream and provide access to its contents in a nice,
easy-to-comprehend API.
This pre-release brings two breaking changes to the KSY language (a new enums syntax and stricter rules for integer types in expressions). All changes outside the “Breaking changes (2.x only)” group will also be part of the next 1.x release. The Python runtime library of this version is available on PyPI as 2.0.0a1, which is how Python spells pre-release versions such as 2.0.0-alpha.1.
Most of the improvements in this version were supported by the NLnet Foundation.
Warning: The .zip and .msi packages of this version no longer include the format library, because many of its .ksy specs aren’t compatible with 2.0 yet (they use the old enums syntax or break the new rules for integer types). Absolute imports such as /common/vlq_base128_le therefore no longer work out of the box. Specs from the format library that are compatible with 2.0 (including everything they import) can still be imported if you pass the directory of a local copy of the format library with -I (--import-path).
From this version on, all version tags of the compiler and the runtime libraries start with v (e.g. v2.0.0-alpha.1). The compiler and the C++/STL, C#, Java, Lua, Perl, PHP and Ruby runtime libraries previously used tags without it (e.g. 0.11). Download URLs of the compiler change accordingly, e.g. https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/v2.0.0-alpha.1/kaitai-struct-compiler-2.0.0-alpha.1.zip.
enums syntax: each enum must declare its underlying integer type in type and list its entries under values; the old syntax is no longer accepted (#1288)
u1 field can use a u2 enum, but not vice versa)doc and doc-ref (#358)s1 and 128..255 are u1 (as before), and all others get the first of s4, u4, s8 and u8 that can hold them (e.g. 0xffff_ffff is u4)?: expressions have well-defined result types (operands narrower than 32 bits are promoted to s4, except in ?:)u4 or u8 operand is a compile error, unless the signed one is s8 and the unsigned one is u4 (e.g. s4_val + u4_val and s8_val + u8_val are errors, s8_val + u4_val is fine); add a cast such as s4_val.as<s8> + u4_val~1 follow the normal rules and are s4, so u4_val & ~1 is a compile error; use ~1.as<u4>u4 or u8 value or to write an integer literal outside the 64-bit rangebX) are stored in the smallest unsigned type that can hold them (e.g. b12 as u2) instead of u8; if your spec relies on 64-bit arithmetic with b2..b32 values (e.g. vlq_base128_be.ksy), cast them with .as<u8>s8, u8 and b33..b64 values are now bigint, so code generated for such fields requires BigInt support (ES2020) - application code using them must be adapted (e.g. for a u8 field foo, obj.foo + 1n instead of obj.foo + 1)
b33..b64 fields (they used to throw a RangeError, because bitwise operations on JavaScript’s number only work with 32 bits)0xffff_ffff is no longer -1 in C++ and Java, ~ on unsigned values is no longer negative, and >> on signed values is now an arithmetic shift in JavaScript)?: with branches of different integer types may fail to compile or give wrong results in C++, C#, Go, Nim, Rust and Zig (see compiler#350 for details)2**63 and 2**64 - 1 (02c287f)--zero-copy-substream, enabled by default) are now supported in Python too, so the generated code no longer has _raw_* fields unless you use --zero-copy-substream false (#44)super() without arguments (#1262)nil (lua#19, e95826f)--no-auto-read (6fc8a13)type: b1 fields are now booleans (#1229)int_from_byte() and byte_array_{index,min,max}() (python@115c3bd)read_bits_int_{be,le}() (python@d810cf4)IAnimal for an enum Animal) instead of the enum type, so that values not defined in the enum are kept (e.g. as IAnimal.Unknown) instead of becoming null - this is a breaking change (compiler#288)
IAnimal; comparisons like obj.animal() == Animal.CAT still workIKaitaiEnum, a common interface for all generated enums (java#42)*AsBigInt() read methods and divBigInt() (javascript#38)mod64() (cpp_stl@c19168f)zeroFillRightShift() public (php@8187d54)enum.is_defined() and enum.to_int() (lua@81e3c38)alignToByte() (as Java and Python already did in 0.11), and the compiler no longer inserts these calls (#1070, #1282)

2.0.0-alpha.1 (pre-release) released 2026-11-26