A simple Express-based http server providing api routes and a simple user frontend for formatting and minifying Minecraft NBT strings. Can be easily self-hosted, a hosted version is available at nbt.booky.dev.
First, clone this repository. Then copy .env.example to .env and configure the environment variables.
If you want to self-host this without using docker:
- Ensure you have NodeJS installed - if you don't have the yarn package manager installed, replace
yarnwith.yarn/releases/*in the following commands - Run
yarn installto install dependencies - Run
yarn run buildto build server/client scripts - Run
yarn run start:prodto start the web process
If you want to self-host this using docker:
- Ensure docker itself and the docker compose plugin are installed
- Write a
docker-compose.override.ymlwhich specifies the network configuration of theappservice, seedocker-compose.override.yml.examplefor an example - Run
docker compose up -d
API_REDIR: The url to redirect to at the/apiroute- Default:
https://github.com/booky10/nbt-formatter-ts
- Default:
HOST: The host to bind on.- Default:
0.0.0.0
- Default:
PORT: The port to bind on.- Default:
8080
- Default:
TRUST_PROXY: Whether to trust headers sent by the client revealing the real client address. Required for rate-limiting to work correctly with e.g. Cloudflare Proxy enabled.- Default:
false
- Default:
FRONTEND_ENABLED: Whether the frontend pages hosted on the/route should be available.- Default:
true
- Default:
FRONTEND_DIRECTORY: The directory where the frontend pages are located at.- Default:
public
- Default:
All API routes have a rate-limit of 5 requests per 30s, per ip. After this, every request will get delayed by an additional 200ms.
This shows a simple user frontend with a textarea for nbt strings.
Example: GET https://nbt.booky.dev/
This just redirects to this GitHub repository, or another URL if changed.
Example: GET https://nbt.booky.dev/api
The body of the request should be the nbt string to format.
The query parameter indent ranges from 0 to 10 with a default of 2.
If it is set to 0, the sent nbt string will be minified. If 1 or greater, everything will be indented with the supplied indention level.
The query parameter resolve specifies whether to resolve certain SNBT features, e.g. booleans or SNBT operations.
Example: POST https://nbt.booky.dev/api/v1/format?indent=4
{ text: "Hello World!", "example:array": [B; true, 1B, 42B ] }