How the /execute Command Works
The /execute command lets you modify the context before running another command. You can change who runs it (as), where it runs (at, positioned), which dimension (in), or add conditions (if, unless). The final run subcommand specifies what to execute.
Common /execute Patterns
Run as every player at their position
Conditional: only if a block exists
Run in the Nether
Negated condition
Subcommand Reference
as / at / positioned (as)— Change the executor and execution position.positioned over— Move to a heightmap top (1.19.4+).rotated (as) / facing (entity) / align / anchored— Control rotation and the block grid.in <dimension>— Run in another dimension.on <relation>— Run as a related entity (attacker, owner, vehicle, …, 1.19.4+).summon <entity>— Summon and continue as it (1.19.4+).if/unless block(s) / entity / score / data / predicate / biome— Conditions that must pass.store result|success score|storage|block|entity|bossbar— Capture the command's result for later use.if/unless function— Run a datapack function conditionally (1.20.3+).if/unless items— Check an item in a block or entity slot (1.20.5+).run <command>— The final command to execute. Must be last and unique.
Need item or block IDs for your conditions? Browse the Minecraft Item ID List or Minecraft Block IDs page.