Minecraft's world is effectively infinite, and so is the disk it will eventually use. A border is the one setting that puts a ceiling on both, and it is worth setting on day one rather than after the world is 40 GB.
The commands you need
| Command | What it does |
|---|---|
worldborder set 10000 | A square 10,000 blocks across, so 5,000 blocks from the centre in each direction. |
worldborder center 0 0 | Where the square is centred. Usually spawn. |
worldborder set 10000 300 | The same size, reached gradually over 300 seconds instead of instantly. |
worldborder warning distance 50 | How close a player gets before the screen starts tinting red. |
worldborder get | Prints the current size, which is the fastest way to check it applied. |
Picking a size
A 10,000-block border gives a square of 100 million blocks. For a group of friends that is more land than anyone will ever explore, and it keeps the world at a size you can back up and download comfortably.
Larger servers with a hundred players often run 20,000 or 30,000. Past that, disk and backup times grow faster than the value of the extra space.
Terrain outside the new border still exists on disk and still counts toward your storage. The border stops people walking there; it does not reclaim the space. Trimming that requires a world-trimming tool.
A border gives a pre-generator an edge to stop at. Without one, chunk pre-generation has no defined end and will happily fill your disk.
worldborder get reports the size you set, and walking towards the edge shows the red warning and then a wall you cannot pass.