In short: NBT (Named Binary Tag) is the file format Minecraft uses to save worlds, players, items and structures. It stores a tree of named values, each with a fixed type such as Byte, Int or String, usually compressed with gzip, which is why a text editor shows gibberish.
NBT, short for Named Binary Tag, is the format Minecraft uses for most of its saved data. It was designed by Notch in the game's early days and has barely changed since. A file is a tree: compounds contain named values, values can be numbers, text, lists or more compounds. What makes NBT different from JSON is that every value has a precise type, and Minecraft relies on those types when it reads the file back.
The 13 tag types
Each tag starts with a one-byte type ID. The badges are the ones the editor shows in front of each name.
| ID | Type | Holds | In SNBT |
|---|---|---|---|
| 0 | End | Marks the end of a compound. Never shown in editors. | |
| 1 | BByte | Whole number from −128 to 127. Also used for true/false (1/0). | 1b |
| 2 | SShort | Whole number from −32,768 to 32,767 | 300s |
| 3 | IInt | Whole number, about ±2.1 billion | 300 |
| 4 | LLong | Whole number, about ±9.2 quintillion (64 bits) | 300L |
| 5 | FFloat | Decimal number, about 7 significant digits | 0.5f |
| 6 | DDouble | Decimal number, about 16 significant digits | 0.5d or 0.5 |
| 7 | B[ ]Byte array | A run of Bytes | [B; 1b, 2b] |
| 8 | StrString | Text, up to 65,535 bytes once encoded | "text" |
| 9 | [ ]List | Unnamed values that all share one type | [1, 2, 3] |
| 10 | { }Compound | Named values of any types | {a: 1, b: "x"} |
| 11 | I[ ]Int array | A run of Ints. UUIDs are stored as four of them. | [I; 1, 2] |
| 12 | L[ ]Long array | A run of Longs, used for packed block data | [L; 1L, 2L] |
How a tag is stored
A named tag is written as its type ID, then the length of its name as a two-byte number, the name itself (in Java's slightly modified UTF-8), and finally the value. A compound is a sequence of named tags followed by an End tag. A list stores the type of its items once, then the item count, then the values without names.
Files have a single root tag, almost always a compound with an empty name. level.dat's root contains one compound named Data, which is why everything in it is one level down.
- { }root
- { }Data
- StrLevelName"world"
- IDataVersion4671
- { }spawn
- I[ ]pos[0, 102, 0]
- { }Data
Why the types matter
Minecraft reads each value with the type it expects. Many numeric reads are forgiving, but lists are not: if the game expects a list of Compounds and finds a list of another type, it treats the list as empty. An inventory saved with the wrong list type comes back empty. Text is not a number either: the old game rule keepInventory is the String "true", and a Byte 1 in its place is ignored.
Lists hold one type only. Since 1.21.5, commands accept lists that mix types, but the file format did not change: such lists are saved with each item wrapped in a compound under an empty name, like [{"": "a"}, {"": 3}].
Compression
Most NBT files are compressed, which is why they look like noise in a text editor. You can tell which method by the first bytes.
| First bytes (hex) | Method | Used by |
|---|---|---|
1F 8B | gzip | level.dat, player files, structure files, most data files |
78 … | zlib | Chunks inside region (.mca) files |
0A | None | servers.dat, and a raw compound in general |
A file must be saved back with the compression it had. Minecraft reads servers.dat without decompressing it, so a gzipped servers.dat is unreadable to the game. The editor detects the method when it opens a file and reuses it when you download.
Java versus Bedrock
Java Edition writes numbers big-endian (most significant byte first). Bedrock Edition writes the same structure little-endian, uncompressed. Bedrock's level.dat also starts with an eight-byte header: a storage version number and the length of the data that follows. When the data changes size, the length must be rewritten, which the editor does. Bedrock's chunks and player data are not single NBT files; they live in a LevelDB database in the world's db folder.
Longs, UUIDs and precision
A Long can hold a 19-digit number, such as a world seed like 6508918960062323141. JavaScript numbers, which JSON-based tools often use, only keep about 16 significant digits, so a careless editor turns that seed into 6508918960062322688. The world then generates different terrain from that point on. This editor keeps Long values as exact text for that reason.
UUIDs, which identify players and entities, are stored as Int arrays of four numbers in current versions. Older data used two Longs named UUIDMost and UUIDLeast.
Where to go next
To write NBT as text, for commands or the editor's SNBT view, read the SNBT guide. To see these rules in practice, the common mistakes guide lists what breaks saves most often.