Updated:

Basic form

/fill <from> <to> <block> [mode]
/fill ~-2 ~-1 ~-2 ~2 ~-1 ~2 minecraft:stone

This makes a 5×5 stone floor one block below you. Start this small until you are sure which way the coordinates point.

Count the blocks first

Both corners are included. From X 0–4, Y 64–66 and Z 0–2 the box is (4−0+1)×(66−64+1)×(2−0+1) = 45 blocks. A quick count shows whether the box is the size you expect.

Modes

ModeWhat it does
replace (default)Replaces everything in the box
destroyBreaks existing blocks as if mined, dropping items
keepOnly fills air
hollowBuilds the outer shell and fills the inside with air
outlineBuilds the outer shell and leaves the inside as it was

Use hollow for a room, outline to wrap something that already exists.

Examples

# A wall 5 blocks east, 5 high and 11 long
/fill ~5 ~ ~-5 ~5 ~4 ~5 minecraft:stone_bricks
# Carve out a small room
/fill ~-3 ~ ~-3 ~3 ~3 ~3 minecraft:air
# Turn only dirt into grass on the floor
/fill ~-5 ~-1 ~-5 ~5 ~-1 ~5 minecraft:grass_block replace minecraft:dirt

Keeping one coordinate the same on both corners gives a flat wall or floor. A block after replace limits the change to that block only.

The size limit

One /fill changes at most 32,768 blocks (32×32×32). Split bigger areas into several commands, and back up the world before large changes.

On Java Edition 1.20.3 and later, this limit is a gamerule, commandModificationBlockLimit (default 32768). It also applies to /clone and /fillbiome. On a test world you can raise it with /gamerule commandModificationBlockLimit 100000, but huge fills can freeze the server for a while. Newer versions may list the rule under a different name, so use tab completion after /gamerule to find it. Bedrock Edition has no such gamerule, so split the area instead.

When it does not work

Common questions

The fill generator keeps the six coordinates and the mode in separate fields so they are easier to check.

Check your command

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