A blazing-fast C++ library for parsing, generating, and manipulating Minecraft Named Binary Tag (NBT) data with benchmarked speeds of 200 MB/s on modern CPUs.
| NBT Format | Minecraft Edition | Support Status |
|---|---|---|
| Little Endian Binary | Bedrock Edition | β |
| Little Endian Binary with Header | Bedrock Edition | β |
| Big Endian Binary | Java Edition | β |
| Big Endian Binary with Header | Java Edition | β |
| Bedrock Network (VarInt Encoding) | Bedrock Edition | β |
| Formatted String (SNBT) | Bedrock & Java Edition | β |
- Ultra-fast parsing - Achieves 200 MB/s processing speed on modern CPUs
- Complete NBT support - All NBT types (Java and Bedrock)
- Full SNBT support - Full SNBT support, include new SNBT format since Java Edition 1.21.5
- Zero-copy design - Minimal memory allocation during parsing
- Streaming interface - Process large NBT files with constant memory footprint
- Cross-platform - Windows, Linux, macOS support
- Endian-aware - Automatic little/big-endian conversion
- Zlib/Gzip support - Built-in compression handling
- Simple API - Intuitive interface inspired by standard libraries
- CFFI - Pure C API support.
using namespace nbt::literals::integral;
// Parsing NBT from file (Automatically detect NBT format and decompress)
auto nbt1 = nbt::io::parseFromFile("./level.dat");
// You can also specify the NBT format
// auto nbtRead = nbt::io::parseFromFile("./level.dat", NbtFileFormat::LittleEndian);
// Craate a CompoundTag in memory
nbt::CompoundTag nbt2 = {
{"Byte", 64_b },
{"Short", 16384_s },
{"Int", 12345678 },
{"Long", 5678900123456_l },
{"Float", 3.14159f },
{"Double", 1.23456789 },
{"String", "homo string" },
{"ByteArray", ByteArrayTag({2, 3, 4, 5, 6, 7, 8, 9}) },
{"List", ListTag() },
{"Compound", CompoundTag() },
{"IntArray", IntArrayTag({212345, 3765432, 4234567})},
{"LongArray", LongArrayTag({45, 432, 244, 524}) },
};
nbt2.toBinaryNbt(); // to binary nbt format
nbt2.toNetworkNbt(); // to network nbt format
// Save NBT to file
nbt::io::saveToFile(nbt2, NbtFileFormat::LittleEndian);
- C++23 compatible compiler (GCC 13+, Clang 17+, MSVC 2022+)
- Xmake 3.0.0+
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
add_requires("nbt")- Build with Xmake
xmake --all- If you want to use Cmake build system, you can generate CmakeLists.txt
xmake project -k cmake| Project | Link |
|---|---|
| ProtocolLib | https://github.com/GlacieTeam/ProtocolLib |
| AntiXray | https://github.com/GlacieTeam/AntiXray |
| RapidNBT | https://github.com/GlacieTeam/RapidNBT |
If you would like to add your project here, please create a pull request.
Contributions are welcome! Please follow these steps:
- Fork the repository and create your feature branch
- Add tests for any new functionality
- Submit a pull request with detailed description
This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).
- Modifications to this project's files must be released under MPL-2.0.
- Static/dynamic linking with closed-source projects is allowed (no requirement to disclose your own code).
- Patent protection is explicitly granted to all users.
For the full license text, see LICENSE file or visit MPL 2.0 Official Page.