How to pregenerate the area around spawn with /pregen
Pregenerating means the world's chunks are created ahead of time, so players exploring later don't trigger terrain, ore and tree generation and cause lag.
Queue a radius task
1. Stand where you want the centre to be, or note its X and Z coordinates. Spawn is a good choice.
2. Open chat or the server console and type /pregen gen. Press Tab after each word. Every command and parameter has autocompletion, so the game shows you what comes next.
3. Choose the radius option. It asks for the shape of the area, the centre coordinates and the size.
4. Pick the dimension if the command offers one. The Overworld, Nether and End are handled as separate tasks.
5. Run the command. This only adds the task to the queue.
Start the run
1. Type /pregen start to begin working through the queue.
2. Large radii take a long time because every chunk must be fully generated.
3. When the task finishes, the area loads without generation lag.
Tip: Start with a small radius to see how fast your machine handles it. Then queue a larger one once you know how long it takes. If you need a non-circular or off-centre region, use the area option under /pregen gen instead.