Kaitai Struct

Katai Struct is a 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.

Links

 * Official site
 * Format gallery