We have begun migration of most wikis to our new host, Amazon Web Services. All but the top 100 wikis are in read-only mode until the migration is complete. Estimated completion: TBD -- Update: Fri 10/20 11pm UTC - We have encountered some unexpected issues. Our staff is working around the clock to complete this process as quickly as possible. Thank you for your patience.

NBT format

From Minecraft Wiki
Revision as of 01:15, 22 June 2012 by LB (talk | contribs) (Article explaining the NBT format)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This article is a stub.
Please help us by expanding it.

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, and since then has been updated to 19133 with Anvil, with the addition of the Int Array tag.

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. 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 11 known tags in version 19133 of the Named Binary Tag format:

ID Tag Type Payload Description
0 TAG_End None Used to mark the end of compound tags.
1 TAG_Byte 1 byte / 8 bits, signed A signed integral type. Sometimes used for booleans.
2 TAG_Short 2 bytes / 16 bits, signed, big endian A signed integral type.
3 TAG_Int 4 bytes / 32 bits, signed, big endian A signed integral type.
4 TAG_Long 8 bytes / 64 bits, signed, big endian A signed integral type.
5 TAG_Float 4 bytes / 32 bits, signed, big endian, IEEE 754-2008, binary32 A signed floating point type.
6 TAG_Double 8 bytes / 64 bits, signed, big endian, IEEE 754-2008, binary64 A signed floating point type.
7 TAG_Byte_Array TAG_Int's payload size, then size bytes. An array of bytes.
8 TAG_String TAG_Short's payload length, then a UTF-8 string with size length. A UTF-8 string. It has a size, rather than being null terminated.
9 TAG_List TAG_Byte's payload tagId, then TAG_Int's payload size, then size tags' payloads, all of type tagId. A list of tag payloads, without repeated tag IDs or any tag names.
10 TAG_Compound Fully formed tags, followed by a TAG_End. A list of fully formed tags, including their IDs, names, and payloads.
11 TAG_Int_Array (?) TAG_Int's payload size, then size*4 bytes. An array of TAG_Int's payloads.

The List and Compound tags can be and often are recursive.

File Format

An NBT file is a GZIPped 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.