Minecraft /execute command

Java EditionBedrock EditionSince Java 1.13 (17w45a) / Bedrock 1.19.50

Quick answer: Runs another command with changed context: as a different entity, at a position, in a dimension, or only if a condition is true. Syntax: 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

EditionSyntax
Javaexecute <as|at|positioned|rotated|facing|align|anchored|in|if|unless|store|summon> ... run <command>
Bedrockexecute <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_block

Put a diamond block under every zombie

/execute if block 100 64 200 minecraft:chest run say Found the chest

Run /say only if there is a chest at those coordinates

/execute in minecraft:the_nether positioned 0 80 0 run summon minecraft:ghast

Summon a ghast in the Nether from the Overworld

Tips

Related commands

/summon/fill/scoreboard