The fastest way to replace blocks is the /fill command with the replace argument

The /fill command lets you select a rectangular area and swap one block type for another in a single line. The syntax is /fill x1 y1 z1 x2 y2 z2 block_name replace old_block_name. For example, /fill 0 60 0 10 70 10 stone replace dirt replaces all dirt blocks with stone in that region.

You need to know the coordinates of two opposite corners of the area you want to fill. The easiest way to find coordinates is to press F3 (on Java Edition) or enable coordinates in your world settings (Bedrock Edition), then stand at each corner and write down the numbers. The command works instantly and affects every matching block in the box you define.

If you want to replace blocks in a larger area without typing huge coordinate numbers, use relative coordinates instead. /fill ~-5 ~-5 ~-5 ~5 ~5 ~5 stone replace dirt replaces dirt with stone in a 10×10×10 cube centered on where you're standing. The tilde (~) means "relative to my position".

Key Takeaways

  • The /fill command with replace swaps one block type for another across a rectangular area you define with two corner coordinates.
  • You can use absolute coordinates (like 0 60 0) or relative coordinates (like ~-5 ~-5 ~-5) depending on whether you know the exact position or want to work from where you're standing.
  • The command executes instantly and affects every matching block in the region, so double-check your coordinates and block names before running it.
  • Block names must match exactly as they appear in the game — use stone, not Stone, and use oak_log, not wood or log.
  • You can also use /setblock to replace a single block at a specific coordinate, which is useful for precise edits.

How to find the exact coordinates you need

On Java Edition, press F3 to open the debug screen. Look for the line that says "XYZ" — those three numbers are your current position. Stand at one corner of the area you want to fill and write down those numbers. Then walk to the opposite corner and write down those coordinates too. You now have everything you need for the /fill command.

On Bedrock Edition (Windows 10, Xbox, mobile), coordinates are not shown by default. Open your world settings, scroll to "Game" options, and toggle "Show Coordinates" to on. The coordinates will appear in the top left corner of your screen. Walk to each corner and record the numbers the same way.

If you are not sure whether you have the right coordinates, you can test with a small area first. Replace a 3×3×3 cube with a temporary block like wool, see if it's in the right place, then undo it with Ctrl+Z and adjust your numbers.

Using /setblock to replace a single block

When you only need to change one block, /setblock is faster than /fill. The syntax is /setblock x y z block_name. For example, /setblock 100 64 200 diamond_block places a diamond block at those exact coordinates, replacing whatever was there before.

You can also add a replace mode to /setblock: /setblock 100 64 200 stone replace. This only works if there is already a block at that location — it will not place a block in air. The replace mode is useful when you want to be certain you are only changing existing blocks, not filling empty space.

Block names you need to know

Block names in commands are not always what they look like in your inventory. Stone is stone, but oak wood is oak_log, not wood. Dirt is dirt, grass is grass_block, and sand is sand. If you use the wrong name, the command will fail and tell you the block does not exist.

The safest way to get the exact name is to hold your cursor over a block in your inventory and look at the tooltip — the name in gray text below the block's display name is the command name. Alternatively, you can type / in the chat, then start typing a block name. Minecraft will show you a list of matching blocks as you type, and you can click one to auto-complete it.

Some blocks have variants. Oak planks are oak_planks, spruce planks are spruce_planks, and so on. If you want to replace only one type of wood plank with stone, you have to name the specific wood type. If you want to replace all planks at once, you cannot do it with a single /fill command — you would need to run the command once for each plank type.

Replacing blocks with specific properties

Some blocks have properties you can set in commands, like whether a log is pointing up or sideways. You add these in square brackets after the block name: /fill 0 60 0 10 70 10 oak_log[axis=y] replace oak_log. This replaces all oak logs with oak logs pointing upward (the y-axis).

Common properties include axis (which direction a log or pillar faces), facing (which way a stair or door opens), and half (whether a slab is on the top or bottom). You can look up properties for any block on the Minecraft wiki by searching the block name and looking for the "Block states" section.

If you want to replace only logs that are already pointing upward, use: /fill 0 60 0 10 70 10 stone replace oak_log[axis=y]. This replaces the old block name with properties in the replace argument, so only matching blocks swap out.

Undoing a /fill command if you make a mistake

If you run a /fill command and realize you made a mistake, press Ctrl+Z (or Cmd+Z on Mac) to undo it. This works in Creative mode and in worlds where you have cheats turned on. Undo will revert the last command you ran, restoring the blocks to what they were before.

If undo does not work, you may have already run another command after the one you want to undo. Each undo only goes back one step. In that case, you can run the /fill command again with the original blocks and the wrong blocks swapped in the replace argument — for example, if you accidentally filled an area with stone when you meant to use dirt, run /fill x1 y1 z1 x2 y2 z2 dirt replace stone to swap them back.

Frequently Asked Questions

Can I replace blocks in a sphere or cylinder shape instead of a rectangle?

/fill only works with rectangular areas. To replace blocks in other shapes, you would need a mod or a more complex command structure using /execute. For a sphere, some players use third-party tools or mods like WorldEdit, which is not a built-in Minecraft command but a separate modification.

What happens if I use /fill on a very large area?

If the area is too large, the command may lag your game or even crash it. Start with smaller areas — a 50×50×50 cube is usually safe. If you need to fill a huge space, break it into smaller /fill commands and run them one at a time with a delay between them.

Do I need to be in Creative mode to use /fill?

No. /fill works in Survival mode as long as cheats are turned on. You can turn cheats on when you create a world, or open your world to LAN and enable cheats from the pause menu. Once cheats are on, you can use any command.

Can I replace blocks that are inside other blocks, like ore inside stone?

/fill replaces blocks based on their type only, not on what is around them. If you want to replace only diamond ore that is surrounded by stone, you cannot do it with /fill alone — you would need a mod or a command structure using /execute with conditions, which is more advanced.

What if the block name has a space or special character in it?

Block names in commands never have spaces. If a block looks like it has a space in your inventory (like "Dark Oak Wood"), the command name uses an underscore instead: dark_oak_log. Always check the gray tooltip name in your inventory to see the correct command spelling.