NBT format

The Named Binary Tag format is used by Minecraft for the various files it saves data to. The format is described by Notch in a very brief specification. The format is designed to store data in a tree structure made of up various tags. All tags have an ID and a name. The original known version was 19132 as introduced in Minecraft Beta 1.3, and since then has been updated to 19133 with Anvil, with the addition of the Int Array tag. The NBT format dates all the way back to Minecraft Indev with tags 0 to 10 in use.

TAG definition
A tag is an individual part of the data tree. The first byte in a tag is the tag type (ID), followed by two bytes for the length of the name, then the name as a string in UTF-8 format. The name of tags may contain spaces, although Minecraft itself never saves tags with spaces in the names. Finally, depending on the type of the tag, the bytes that follow are part of that tag's payload. This table describes each of the 12 known tags in version 19133 of the Named Binary Tag format: The List and Compound tags can be and often are recursively nested.

File Format
An NBT file is a GZip'd Compound tag, name and tag ID included. Some of the files utilized by Minecraft may be uncompressed, but in most cases the files follow Notch's original specification and are compressed with GZip. There is no header to specify the version or any other information - only the level.dat file specifies the version.

As used in Minecraft
Minecraft's use of the NBT format is odd at times. In some instances, empty lists may be represented as a list of Byte tags rather than a list of the correct type. Additionally, almost every root tag has the name "" and encapsulates only one Compound tag with the actual data and a name. For instance: Another noticeable oddity is that, although the original specification by Notch allows for spaces in tag names, and even the example uses spaces in the tag names, Minecraft has no know files where any tags have spaces in their names. There is also inconsistent use of letter case, mostly either lowerCamelCase or UpperCamelCase, but sometimes even in alllowercase.
 * TAG_Compound(""): The root tag for most Minecraft NBT structures.
 * TAG_Compound("SomeName"): The only tag contained within the root tag - it has a name and contains all the actual data.

Uses

 * level.dat is stored in compressed NBT format.
 * .dat files are stored in compressed NBT format.
 * idcounts.dat is stored in uncompressed NBT format.
 * map_<#>.dat files are stored in compressed NBT format.
 * Chunks are stored in compressed NBT format within Region files.

Software
While there is no official software for the NBT format other than Minecraft itself, the community has developed programs to view and modify compressed and uncompressed NBT files.