Menu
Skip to article

The /fill Command in Minecraft: Syntax, Modes and Examples

How /fill works in Java and Bedrock: corner coordinates, relative ~ positions, every fill mode with examples, the block limit and common…

5616 min
Guide

The /fill command fills a rectangular area with one block in a single step. Use it to raise walls, dig out a foundation pit for an underground base, flood a pool, drain a lake or swap one block for another across a whole area, all without mining or placing blocks by hand. It needs cheats in singleplayer or operator rights on a server.

Key facts about the command:

  • Command: /fill

  • Maximum volume per command: 32,768 blocks by default. In Java Edition the limit is set by the max_block_modifications game rule (commandModificationBlockLimit before 1.21.11); in Bedrock Edition it is fixed.

  • Relative coordinates: ~ (tilde), counted from the position where the command runs

  • Modes: replace, keep, outline, hollow, destroy, plus strict in Java 1.21.5 and newer

  • Permissions: cheats enabled (Allow Cheats: ON) or operator rights (OP)

Syntax of the /fill command

The command takes two opposite corners of a box (the ends of its diagonal) and fills every block between them, corners included.

Java Edition syntax

/fill <x1> <y1> <z1> <x2> <y2> <z2> <block> [mode]
/fill <x1> <y1> <z1> <x2> <y2> <z2> <block> replace <filter> [mode]

The filter only goes after replace. Since 1.21.5 you can add outline, hollow, destroy or strict after the filter; in older versions replace <filter> ends the command.

Bedrock Edition syntax

/fill <x1> <y1> <z1> <x2> <y2> <z2> <block> [block states] [mode]
/fill <x1> <y1> <z1> <x2> <y2> <z2> <block> [block states] replace [filter block] [filter block states]

Bedrock used numeric data values here until 1.19.70; current versions take block states in square brackets instead.

Parameters

  • x1 y1 z1: coordinates of the first corner of the area.

  • x2 y2 z2: coordinates of the opposite corner.

  • <block>: the block ID, for example stone, dirt, glass, air or water. Block states are optional: oak_log[axis=x] in Java, oak_log ["pillar_axis"="x"] in Bedrock.

  • <filter>: which blocks to replace. In Java it can be a block with states or a block tag such as #minecraft:logs.

A /fill command filling the box between two corner coordinates with blocks in a Minecraft world

Relative coordinates with the tilde (~)

You don't have to look up exact numbers: the ~ (tilde) means the current position of the player running the command, and a number after it is an offset from that position.

Examples of relative coordinates

  • ~ ~ ~: the player's current position (the block at their feet).

  • ~5 ~10 ~5: 5 blocks east, 10 blocks up and 5 blocks south of the player. Positive X points east and positive Z points south.

Example: a 5×5×5 stone cube around the player

/fill ~-2 ~0 ~-2 ~2 ~4 ~2 stone

This instantly places a solid stone cube 5 blocks wide, 5 deep and 5 high starting at the player's feet. The player ends up inside it, so step aside first or use hollow to get an empty room.

Modes of the /fill command

The optional mode at the end of the command changes how existing blocks in the area are treated.

replace (default)

Replaces every block in the area, air included, with the chosen block. Add a filter to change only one type of block:

/fill ~-10 ~0 ~-10 ~10 ~5 ~10 stone replace dirt

This turns only dirt (dirt) inside the area into stone (stone) and leaves grass blocks, water and everything else untouched.

Dirt in the selected area turning into stone after /fill with replace dirt, while grass blocks stay unchanged

hollow (empty room)

Builds only the outer walls, floor and ceiling from the chosen block and clears everything inside to air. The quickest way to make an empty house or an underground room.

/fill ~-5 ~0 ~-5 ~5 ~5 ~5 bricks hollow
A hollow brick box with an empty interior built with /fill ~-5 ~0 ~-5 ~5 ~5 ~5 bricks hollow

outline (shell only)

Also replaces only the outer layer of the area, but leaves the blocks inside as they are.

An outline of blocks built around an area with /fill outline while the blocks inside stay in place

keep (fill empty space)

Places the block only where there is air. Every other block, including water, lava and plants, stays where it is.

Blocks filling only the air gaps of an area with /fill keep, existing blocks left untouched

destroy (break and drop)

Fills the area with the new block after breaking the old blocks and dropping them as items, as if they had been mined with a diamond pickaxe or shovel.

Be careful with destroy: breaking thousands of blocks at once leaves thousands of dropped items on the ground and can make the game lag badly.

strict (Java Edition 1.21.5+)

Places blocks exactly as specified without triggering block updates or shape updates: neighbouring blocks don't react, and fences, walls and glass panes keep the shape you gave them instead of connecting to their neighbours. There is no such mode in Bedrock Edition.

Useful /fill commands

  1. Clear an area (dig a pit of air):

    /fill ~-10 ~0 ~-10 ~10 ~10 ~10 air
  2. Fill a pool with water:

    /fill ~-5 ~-1 ~-5 ~5 ~-3 ~5 water
  3. Remove all water nearby (drain a lake):

    /fill ~-15 ~-5 ~-15 ~15 ~5 ~15 air replace water

    Waterlogged blocks, kelp and seagrass are not the water block, so they stay.

  4. Turn all grass blocks into smooth stone:

    /fill ~-20 ~0 ~-20 ~20 ~0 ~20 smooth_stone replace grass_block

Modes compared

Mode

Outer layer

Blocks inside

Best for

replace

Replaced with the new block

Replaced with the new block

Building solid masses

hollow

Replaced with the new block

Cleared to air

Empty rooms and houses

outline

Replaced with the new block

Left unchanged

Encasing existing builds

keep

Replaces air only

Replaces air only

Filling caves safely

destroy

Replaced, old blocks drop

Replaced, old blocks drop

Simulating mining

strict (Java)

Replaced without block updates

Replaced without block updates

Placing blocks without disturbing neighbours

Common errors and fixes

"Too many blocks in the specified area"

One command can change at most 32,768 blocks by default. Split the area into several smaller boxes or lower its height. In Java Edition you can raise the limit with the game rule /gamerule max_block_modifications 100000 (in 1.19.4–1.21.10 it is called commandModificationBlockLimit). Bedrock Edition has no such setting.

"That position is not loaded" or "Cannot place blocks outside of the world"

Part of the area is in unloaded chunks or outside the world's height limits. Java Edition reports "That position is not loaded" or "That position is out of this world!", Bedrock Edition reports "Cannot place blocks outside of the world". Move closer to the target area and check the Y coordinates.

The command doesn't work in singleplayer

Make sure cheats are enabled in your world. In Java Edition press Esc → Open to LAN → Allow Cheats: ON → Start LAN World; this lasts until you leave the world. In Bedrock Edition turn on Activate Cheats in the world settings.