Minecraft /execute command
Java EditionBedrock EditionSince Java 1.13 (17w45a) / Bedrock 1.19.50
execute <as|at|positioned|rotated|facing|align|anchored|in|if|unless|store|summon> ... run <command>/execute is the most powerful command in Minecraft. It chains subcommands that change who runs the command (as), where (at, positioned), in which dimension (in), and under which conditions (if, unless), finishing with run followed by any command. It can also store results into scores, boss bars or block/item data with store. Bedrock Edition adopted the same chained syntax in 1.19.50; the old Bedrock 'execute <origin> <position> <command>' form is legacy.
Syntax
| Edition | Syntax |
|---|---|
| Java | execute <as|at|positioned|rotated|facing|align|anchored|in|if|unless|store|summon> ... run <command> |
| Bedrock | execute <subcommands...> run <command> |
Targets / arguments: Any entity or position; @s refers to the current executor. Requires: Cheats enabled / operator level 2 (Java), 1 (Bedrock).
Examples
/execute as @e[type=zombie] at @s run setblock ~ ~-1 ~ minecraft:diamond_blockPut a diamond block under every zombie
/execute if block 100 64 200 minecraft:chest run say Found the chestRun /say only if there is a chest at those coordinates
/execute in minecraft:the_nether positioned 0 80 0 run summon minecraft:ghastSummon a ghast in the Nether from the Overworld
Tips
- Chain as many subcommands as you need: execute as @a at @s if block ~ ~-1 ~ grass_block run effect give @s speed 5.
- /execute store result lets you capture a command's output into a scoreboard score or boss bar.
- Test conditions with if/unless instead of long redstone comparators.