A command line utitlity and module that reads NBT data and converts it to JSON or YAML for editing and then back to NBT again
Alternatives To Nbt2json
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
a day ago1,168mitJavaScript
Prettier is an opinionated code formatter.
Cli20,2123,0703,59411 hours ago137September 11, 202245mitGo
A simple, fast, and fun package for building command line apps in Go
Yq8,695432 days ago10February 06, 202074mitGo
yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
Structured Text Tools6,672
a month ago15
A list of command line tools for manipulating structured text data
5 days ago90July 06, 202222mitPython
CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
Countries5,7093997722 days ago21April 04, 202037odbl-1.0PHP
World countries in JSON, CSV, XML and Yaml. Any help is welcome!
Countries States Cities Database4,908
8 days ago41odbl-1.0PHP
🌍 Discover our global repository of countries, states, and cities! 🏙️ Get comprehensive data in JSON, SQL, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities
Dasel4,244711 hours ago80August 24, 202226mitGo
Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package.
Tablib4,2421,179802 months ago41April 09, 202235mitPython
Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
Tmuxp3,6943963 days ago175May 27, 202290mitPython
:computer: tmux session manager. built on libtmux
Alternatives To Nbt2json
Select To Compare

Alternative Project Comparisons


A command line utility and Go module that reads NBT data and converts it to JSON or YAML for editing and then back to NBT.


  • nbt2json executable will auto-detect and decompress gzipped files
  • nbt2json executable has option to gzip output
  • Can read and write both Minecraft Bedrock Edition and Java Edition NBT data
    • Does not auto-detect which
    • nbt2json executable defaults to Bedrock Edition / little endian
  • Can import to other Go projects
  • Can use either JSON or YAML
  • Can include comment in JSON/YAML output (which is ignored when converting back to NBT)

Help screen

By defualt, the nbt2json executable waits for input from stdin, so you need to nbt2json -h to see the help screen.

   NBT to JSON - Converts NBT-encoded data to JSON | https://github.com/midnightfreddie/nbt2json

   nbt2json.exe [global options] command [command options] [arguments...]


   Jim Nelson <[email protected]>

   help, h  Shows a list of commands or help for one command

   --reverse, -r                  Convert JSON to NBT instead (default: false)
   --gzip, -z                     Compress output with gzip (default: false)
   --comment COMMENT, -c COMMENT  Add COMMENT to json or yaml output, use quotes if contains white space
   --big-endian, --java, -b       Use for Minecraft Java Edition (like most other NBT tools) (default: false)
   --in FILE, -i FILE             Input FILE path (default: "-")
   --out FILE, -o FILE            Output FILE path (default: "-")
   --yaml, --yml, -y              Use YAML instead of JSON (default: false)
   --long-as-string, -l           If set, nbt long values will be a string instead of uint32 pair (default: false)
   --skip NUM                     Skip NUM bytes of NBT input. For Bedrock's level.dat, use --skip 8 to bypass header (default: 0)
   --help, -h                     show help (default: false)
   --version, -v                  print the version (default: false)

   (c) 2018, 2019, 2020 Jim Nelson


This repo is both a Go module and a command line utility. To build the utility:

  • Ensure Go v1.16 or later is installed and configured (GOPATH is set)
  • cd into repo root folder
  • go build ./cmd/nbt2json will put the executable in the current directory. Important: include the ./ at the beginning or else it will throw "package cmd/nbt2json is not in GOROOT". (I do that. Every. Time.)

JSON format notes

The JSON document should be an object with an "nbt" field which is an array. Objects in the array represent one tag and will typically have tagType, name, and value fields. A typical Minecraft NBT will have one compound tag with a number of other tags inside that one. This converter needs at least one tag.

Many JSON libraries cannot properly handle a 64-bit integer, so nbt2json handles the long tag in one of two special ways for portability and compatibility.

By default it presents valueLeast and valueMost unsigned 32-bit integers. valueMost is the most significant 32 bits, so it should be rolled bitwise to the left 32 bits in a 64-bit space and added (or bitwise 'or'ed) to valueLeast to reassemble the 64-bit long singed integer. Here is an example:

  "nbt": [
      "tagType": 4,
      "name": "LongAsUint32PairExample",
      "value": {
        "valueLeast": 4294967295,
        "valueMost": 2147483647

Alternately it can turn the 64-bit integer into a string. This would be easier to edit by hand in a text editor. Example:

  "nbt": [
      "tagType": 4,
      "name": "LongAsStringExample",
      "value": "9223372036854775807"

Dev notes

  • Client Go code needs to import "github.com/midnightfreddie/nbt2json"
  • Defaults to little-endian encoding for Bedrock Edition. Call nbt2json.UseJavaEncoding() and nbt2json.UseBedrockEncoding() to change encoding mode for as long as the module is open.
  • The functions use byte arrays where you might expect strings. Convert as such: var myString = someByteArray[:] or var myByteArray = []byte(someStringValue)
  • All errors should bubble up through the error part of the result and should describe where the problem was
  • The Json2Nbt function uses an interface{} and encodes based on the tagType fields. I had originally hoped to Marshal and Unmarshal to and from JSON and NBT, but my goal was to export to JSON, edit and then reencode. This way the struct doesn't have to match the data schema.
  • My main motivation for this project is to convert to/from JSON and use any JSON editor to modify Minecraft PE data with McpeTool, and to keep the read/write primitives in Go code while letting a client browser manage any validation to avoid having to re-release the read/write tools every time Minecraft changes formats.

Exported Go functions

  • Nbt2Yaml converts uncompressed NBT byte array to YAML byte array

      func Nbt2Yaml(b []byte, comment string) ([]byte, error)
  • Nbt2Json converts uncompressed NBT byte array to JSON byte array

      func Nbt2Json(b []byte, comment string) ([]byte, error)
  • Yaml2Nbt converts JSON byte array to uncompressed NBT byte array (Hint: You can just use this for both JSON and YAML if you like since JSON is a valid subeset of YAML)

      func Yaml2Nbt(b []byte) ([]byte, error)
  • Json2Nbt converts JSON byte array to uncompressed NBT byte array

      func Json2Nbt(b []byte) ([]byte, error)
  • UseJavaEndoding sets any nbt encoding/decoding to big-endian to match Minecraft Java Edition

      func UseJavaEncoding()
  • UseBedrockEncoding sets nbt encoding/decoding to little-endian to match Minecraft Bedrock Edition (default)

      func UseBedrockEncoding()
  • UseLongAsString sets json output for nbt long tags to numbers in strings

      func UseLongAsString()
  • UseLongAsUint32Pair sets json output for nbt long tags to a uint32 pair (default, needed for json portability)

      func UseLongAsUint32Pair()

Other exports of possible interest are in common.go.

Popular Yaml Projects
Popular Json Projects
Popular Data Formats Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.