Kaitai Struct
From Just Solve the File Format Problem
Kaitai Struct is a YAML-based declarative language for describing binary data structures (for file formats or internally for programs), with tools to convert it to various programming languages. Its compiler and libraries are open-source. Its creators have created a format gallery describing a number of file formats; pages in it are linked from the infoboxes of relevant formats in this site.