The fastest way to replace blocks is the /fill command with the replace parameter
The /fill command lets you select a rectangular area and swap one block type for another when ready. You type the command, specify two opposite corners of your box, name the block you want to remove and the block you want to place, and Minecraft does the work. This is how builders reshape terrain, clear out old structures, or test designs without breaking blocks by hand.
The basic shape is: /fill X1 Y1 Z1 X2 Y2 Z2 block_name replace old_block_name. The coordinates are the corners of your box. The block_name is what goes in. The old_block_name is what gets removed. If you leave out the replace parameter, the command fills the entire box with the new block, which is useful for solid structures but not for selective swaps.
You need to enable command blocks or have cheats on in your world. In a single-player world, press Escape, click "Open to LAN", turn on "Allow Cheats", and click "Start LAN World". In a server or realm, you need operator permissions. Once cheats are on, press the forward slash key to open the command box and type your command.
Key Takeaways
- The /fill command with replace swaps one block type for another across a rectangular area you define by coordinates.
- You must enable cheats in single-player worlds or have operator status on servers before any command will work.
- Coordinates are the X, Y, and Z positions of two opposite corners of the box you want to fill; you can find your current coordinates in the debug screen.
- The /setblock command replaces a single block at one location, while /fill handles large areas faster than clicking each block individually.
- Block names in commands use underscores instead of spaces, so oak wood is oak_wood and dark oak is dark_oak.
Finding your coordinates so the command targets the right area
Minecraft tracks your position in three dimensions: X (east-west), Y (height), and Z (north-south). You need two sets of coordinates to define opposite corners of a box. The easiest way to find them is to turn on the debug screen by pressing F3 on Java Edition or enabling coordinates in the settings on Bedrock Edition.
Walk to one corner of the area you want to replace and write down the X, Y, and Z numbers. Then walk to the opposite corner (diagonally across, not just to the side) and write down those numbers too. It does not matter which corner you pick first. The command will work the same whether you go from northwest to southeast or any other direction.
If you are not sure which direction is which, remember that positive X goes east, negative X goes west, positive Z goes south, and negative Z goes north. Y is always vertical, with higher numbers meaning higher up. Once you have both sets of numbers, you are ready to build your command.
Using /setblock to replace a single block at a time
The /setblock command works like /fill but for one block only. The syntax is: /setblock X Y Z block_name. You give it one coordinate and one block type, and it places that block at that location. This is useful when you want to swap out a single block without affecting anything around it, or when you are testing what a block looks like in a specific spot.
/setblock does not have a replace parameter because it always overwrites whatever is at that location. If you want to keep the old block type and only replace it if it matches something specific, use /fill with replace instead. /setblock is faster to type for one-off changes and does not require you to calculate a second corner.
Block names and how to spell them correctly in commands
Minecraft block names in commands use lowercase letters and underscores instead of spaces. Oak wood is oak_wood, not "oak wood" or "Oak Wood". Dark oak is dark_oak. Smooth stone is smooth_stone. If you spell a block name wrong, the command will fail and Minecraft will tell you the block does not exist.
The safest way to find the exact name is to hold your cursor over a block in your inventory and look at the name in the tooltip. That is the name Minecraft uses internally. You can also look up block names on the official Minecraft wiki, which lists every block and its command name. Copy the name exactly as it appears, including underscores and lowercase letters.
Some blocks have variants you can add after the name in curly braces. For example, oak_log{axis=y} specifies which direction the log is facing. Most of the time you do not need variants — the command will place the block in its default state. But if you want a log pointing sideways instead of up and down, variants let you control that.
Replacing blocks in a specific pattern or shape
The /fill command fills a rectangular box, so if you want to replace blocks in a circle, diagonal line, or other shape, you have two options. You can run multiple /fill commands, each one covering part of the shape, and overlap them until you get the outline you want. This takes more commands but gives you precise control.
The other option is to use a structure block or world edit mod if you are playing on a server or using a mod loader. Structure blocks are built into Minecraft and let you save and load 3D shapes. Mods like WorldEdit add commands that can fill circles, spheres, and other shapes directly. Since you came from the mods guide, you already know how to find and install mods safely — WorldEdit is one of the most common ones for this kind of work.
For most building projects, overlapping rectangles work fine. Draw out your shape on paper first, break it into boxes, and run one /fill command for each box. It sounds like more work, but it is faster than placing blocks by hand and more reliable than trying to eyeball a freehand shape.
Common mistakes that make commands fail
The most common error is forgetting to enable cheats. If you type a command and nothing happens, check that cheats are on. In single-player, go back to the world menu and look for the "Allow Cheats" toggle. On a server, ask the owner to give you operator status or enable command blocks.
The second most common mistake is misspelling the block name or using spaces instead of underscores. Minecraft is strict about this. If the command does not work, copy the block name from the wiki or from the tooltip in your inventory and paste it into the command exactly.
A third mistake is using the wrong coordinates. If your /fill command replaces blocks in the wrong place, double-check that you copied the numbers correctly and that you are using the right corners. It is straightforward to swap X and Z or to use the wrong Y value. Run the command again with corrected numbers.
Finally, some players forget that /fill replaces everything in the box unless they add the replace parameter. If you want to swap only one block type and leave everything else alone, always include replace old_block_name at the end of the command.
Frequently Asked Questions
Can I undo a /fill command if I replace the wrong blocks?
Yes, if you have not closed the world. Press Ctrl+Z (or Cmd+Z on Mac) to undo the last command. If you have already saved and closed the world, you will need to reload from a backup or manually replace the blocks. Always save a backup of your world before running large /fill commands on important builds.
What is the difference between /fill and /setblock?
/setblock places or replaces a single block at one location. /fill replaces all blocks in a rectangular area. Use /setblock for one block, /fill for large areas. /fill is much faster when you need to change hundreds of blocks at once.
Do I need to be in creative mode to use commands?
No, commands work in survival mode too, as long as cheats are enabled. You do not need to be in creative mode. You can use /fill to reshape terrain or clear out old builds while playing survival normally.
Can I replace blocks that are inside other blocks, like ore inside stone?
No, /fill only replaces blocks that are fully exposed or that match the block type you specify. If you want to replace all stone blocks in an area, /fill will do that. But if you want to replace only the ore inside the stone without touching the stone itself, you need to use the replace parameter and specify the ore block name, not the stone.
What happens if my coordinates are too far apart?
Minecraft has a limit on how large a /fill command can be. On most servers, the limit is around 32,768 blocks in one command. If you try to fill a larger area, the command will fail. Break your large area into smaller boxes and run multiple commands instead.