Updated:

Basic setup

/worldborder center 0 0
/worldborder set 200

center sets the X and Z coordinates of the middle of the border. set sets the length of one side of the square, which is the diameter, not the radius. In this example players can move inside a 200 by 200 block square around 0, 0.

A new world starts with the center at 0, 0 and a size of 59,999,968 blocks. Use /worldborder get to check the current size.

Shrinking the border over time

Add a time after the size and the border moves smoothly to the new size over that time. Java Edition 1.21.11 changed the unit of this time argument from seconds to ticks (20 ticks = 1 second).

VersionShrink to 50 blocks over 5 minutes
1.21.11 and later/worldborder set 50 300s (with s the number is seconds; without it, ticks)
1.21.10 and earlier/worldborder set 50 300 (the number is seconds)

In 1.21.11 and later, /worldborder set 50 300 means 300 ticks, which is only 15 seconds. Many older tutorials use plain numbers, so add the s suffix on current versions. Since 1.21.11 the border also follows game ticks, so it stops moving while the game is paused and respects /tick changes.

Grow or shrink from the current size

/worldborder add 100
/worldborder add -50 60s

add changes the current size. The first line makes each side 100 blocks longer. The second line (1.21.11 and later) shrinks it by 50 blocks over 60 seconds.

Damage and warnings

CommandMeaningDefault
/worldborder damage amount 1Damage per second for each block a player is outside the border0.2
/worldborder damage buffer 2Distance outside the border with no damage5 blocks
/worldborder warning distance 10The screen edge turns red within this distance5 blocks
/worldborder warning time 15The screen turns red when a moving border will reach the player within this time15 seconds

On 1.21.11 and later, write times with the s suffix to be safe.

Minigame example

For 1.21.11 and later: center the border on the start point, start at 300 blocks and shrink to 30 blocks over 10 minutes.

/worldborder center ~ ~
/worldborder set 300
/worldborder damage amount 1
/worldborder set 30 600s

On 1.21.10 and earlier, use /worldborder set 30 600 for the last line.

Common problems

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.