/setblock Command in Minecraft Java Edition

Place or Replace Single Blocks at Coordinates

Java EditionWorld & BlocksPermission: Level 2Bedrock version →

The /setblock command lets you change a single block at a specific location in your Minecraft world into a different block. You can specify the exact coordinates and choose the block ID along with its block states and NBT data.

Players and map makers often use this command to automate building tasks, reset blocks in custom minigames, or clear single blocks by placing air. Because it modifies the world directly, you need Level 2 operator permissions or cheats turned on in single-player to run it.

Syntax (Java 26.3, 5 forms)

  1. /setblock <pos> <block>
  2. /setblock <pos> <block> destroy
  3. /setblock <pos> <block> keep
  4. /setblock <pos> <block> replace
  5. /setblock <pos> <block> strict

The forms you will use most

/setblock <pos> <block>
Places the specified block at the target position using the default handling mode.
/setblock <pos> <block> destroy
Places the new block at the position using the destroy mode for the old block.
/setblock <pos> <block> keep
Places the new block at the position using the keep mode.
/setblock <pos> <block> replace
Places the new block at the position using the replace mode.
/setblock <pos> <block> strict
Places the new block at the position using the strict mode introduced in Java Edition 1.21.5.

Arguments

ArgumentTypeWhat it means
<pos>block positionA block position made of three x y z coordinates, which can use ~ for relative positions or ^ for local positions.
<block>blockThe block ID to place, optionally including block states in square brackets and NBT data.

Examples

Version history

Measured from the game files of every Java release from 1.13 to 26.3.

  1. 1.21.5 Syntax changed.
    + /setblock <pos> <block> strict
  2. 1.13 Already in the game in 1.13, the oldest Java version we track.

Tips

Common mistakes

Java vs Bedrock

Bedrock Edition also includes the /setblock command, but it separates the block ID and block properties into distinct arguments: /setblock <position: x y z> <tileName: Block> <blockStates: block properties> [oldBlockHandling: SetBlockMode].

See /setblock in Bedrock Edition →

FAQ

What permission level do I need to use /setblock?

You need Level 2 operator permissions to run /setblock on a multiplayer server, or you must have cheats turned on in a single-player world.

When was the strict option added to /setblock?

The /setblock <pos> <block> strict syntax form was added in Minecraft Java Edition 1.21.5 and remains available in version 26.3.

How do I choose which direction a placed block faces?

You can append block states in square brackets directly to the block ID in the <block> argument, such as oak_stairs[facing=east].

Related commands

/clone/difficulty/fill/fillbiome/forceload/gamerule/locate/place/seed/setworldspawn/time/waypoint/weather/worldborder

More on 9Minecraft