/execute Command
Executes another command with a modified context (executor, position, dimension, rotation, anchor). Fourteen subcommand types can be chained before the terminal `run` subcommand, or used alone as condition checks. Java-exclusive features include `store`, `on`, `summon`, `if function`, `if items`, `if dimension`, and `if biome`.
execute <subcommand> [...] run <command>
Modify subcommands:
as <entity>
at <entity>
in <dimension>
positioned <pos>
positioned as <entity>
rotated <rot>
rotated as <entity>
anchored (eyes|feet)
facing <pos>
facing entity <entity> (eyes|feet)
on (attacker|controller|leasher|origin|owner|passengers|target|vehicle)
summon <entity_type>
Condition subcommands (if|unless):
(if|unless) block <pos> <block>
(if|unless) blocks <start> <end> <destination> (all|masked)
(if|unless) biome <pos> <biome>
(if|unless) data (block <pos>|entity <entity>|storage <resource_location>) <path>
(if|unless) entity <entity>
(if|unless) loaded <pos>
(if|unless) predicate <predicate>
(if|unless) score <target> <targetObjective> (matches <range>|(<|<=|=|>=|>) <source> <sourceObjective>)
(if|unless) dimension <dimension>
(if|unless) function <function>
(if|unless) items (block <pos>|entity <entity>) <slot> <item_predicate>
Store subcommands:
store (result|success) (block <pos>|bossbar <id> (max|value)|entity <entity>|score <targets> <objective>|storage <resource_location>) <path> <type> <scale>Examples
execute as @e[type=creeper] at @s run kill @sexecute if block ~ ~-1 ~ minecraft:grass_block run say Standing on grass!execute store result score @s my_score run data get entity @s Health 1execute as @a[scores={deaths=10..}] run title @s actionbar {"text":"10 deaths reached","color":"red"}Notes
Java Edition only for: store subcommand, on <relation>, summon subcommand, if/unless biome/dimension/function/items/loaded. The `on` subcommand selects related entities (attacker, controller, leasher, origin, owner, passengers, target, vehicle). `summon` creates the entity and immediately switches context to it. Added in 1.13 (new form); `on` and `summon` added in 1.19.4; `if biome`, `if loaded`, `if function`, `if items` added in later snapshots leading to 1.21.