Run Commands from Any Context or Condition
The /execute command lets you change who is running a command, where it happens, and which conditions must be met before it runs. You can chain multiple subcommands together to check blocks, entities, scores, biomes, or dimensions in a single line.
Players and map makers use it in command blocks and data packs to build custom game mechanics, check player inventories, and trigger events only when specific rules are true. It requires permission level 2, which means you need operator rights or cheats enabled in single-player.
/execute align <axes> → execute …/execute anchored <anchor> → execute …/execute as <targets> → execute …/execute at <targets> → execute …/execute facing <pos> → execute …/execute facing entity <targets> <anchor> → execute …/execute if biome <pos> <biome> […execute]/execute if block <pos> <block> […execute]/execute if blocks <start> <end> <destination> all […execute]/execute if blocks <start> <end> <destination> masked […execute]/execute if data block <source> <path> […execute]/execute if data entity <source> <path> […execute]/execute if data storage <source> <path> […execute]/execute if dimension <dimension> […execute]/execute if entity <entities> […execute]/execute if function <name> → execute …/execute if items block <source> <slots> <item_predicate> […execute]/execute if items entity <source> <slots> <item_predicate> […execute]/execute if loaded <pos> […execute]/execute if predicate <predicate> […execute]/execute if score <target> <targetObjective> < <source> <sourceObjective> […execute]/execute if score <target> <targetObjective> <= <source> <sourceObjective> […execute]/execute if score <target> <targetObjective> = <source> <sourceObjective> […execute]/execute if score <target> <targetObjective> > <source> <sourceObjective> […execute]/execute if score <target> <targetObjective> >= <source> <sourceObjective> […execute]/execute if score <target> <targetObjective> matches <range> […execute]/execute if slots block <source> <slots> […execute]/execute if slots entity <source> <slots> […execute]/execute if stopwatch <id> <range> […execute]/execute in <dimension> → execute …/execute on attacker → execute …/execute on controller → execute …/execute on leasher → execute …/execute on origin → execute …/execute on owner → execute …/execute on passengers → execute …/execute on target → execute …/execute on vehicle → execute …/execute positioned <pos> → execute …/execute positioned as <targets> → execute …/execute positioned over <heightmap> → execute …/execute rotated <rot> → execute …/execute rotated as <targets> → execute …/execute run <any command>/execute store result block <target> <path> byte <scale> → execute …/execute store result block <target> <path> double <scale> → execute …/execute store result block <target> <path> float <scale> → execute …/execute store result block <target> <path> int <scale> → execute …/execute store result block <target> <path> long <scale> → execute …/execute store result block <target> <path> short <scale> → execute …/execute store result bossbar <id> max → execute …/execute store result bossbar <id> value → execute …/execute store result entity <target> <path> byte <scale> → execute …/execute store result entity <target> <path> double <scale> → execute …/execute store result entity <target> <path> float <scale> → execute …/execute store result entity <target> <path> int <scale> → execute …/execute store result entity <target> <path> long <scale> → execute …/execute store result entity <target> <path> short <scale> → execute …/execute store result score <targets> <objective> → execute …/execute store result storage <target> <path> byte <scale> → execute …/execute store result storage <target> <path> double <scale> → execute …/execute store result storage <target> <path> float <scale> → execute …/execute store result storage <target> <path> int <scale> → execute …/execute store result storage <target> <path> long <scale> → execute …/execute store result storage <target> <path> short <scale> → execute …/execute store success block <target> <path> byte <scale> → execute …/execute store success block <target> <path> double <scale> → execute …/execute store success block <target> <path> float <scale> → execute …/execute store success block <target> <path> int <scale> → execute …/execute store success block <target> <path> long <scale> → execute …/execute store success block <target> <path> short <scale> → execute …/execute store success bossbar <id> max → execute …/execute store success bossbar <id> value → execute …/execute store success entity <target> <path> byte <scale> → execute …/execute store success entity <target> <path> double <scale> → execute …/execute store success entity <target> <path> float <scale> → execute …/execute store success entity <target> <path> int <scale> → execute …/execute store success entity <target> <path> long <scale> → execute …/execute store success entity <target> <path> short <scale> → execute …/execute store success score <targets> <objective> → execute …/execute store success storage <target> <path> byte <scale> → execute …/execute store success storage <target> <path> double <scale> → execute …/execute store success storage <target> <path> float <scale> → execute …/execute store success storage <target> <path> int <scale> → execute …/execute store success storage <target> <path> long <scale> → execute …/execute store success storage <target> <path> short <scale> → execute …/execute summon <entity> → execute …/execute unless biome <pos> <biome> […execute]/execute unless block <pos> <block> […execute]/execute unless blocks <start> <end> <destination> all […execute]/execute unless blocks <start> <end> <destination> masked […execute]/execute unless data block <source> <path> […execute]/execute unless data entity <source> <path> […execute]/execute unless data storage <source> <path> […execute]/execute unless dimension <dimension> […execute]/execute unless entity <entities> […execute]/execute unless function <name> → execute …/execute unless items block <source> <slots> <item_predicate> […execute]/execute unless items entity <source> <slots> <item_predicate> […execute]/execute unless loaded <pos> […execute]/execute unless predicate <predicate> […execute]/execute unless score <target> <targetObjective> < <source> <sourceObjective> […execute]/execute unless score <target> <targetObjective> <= <source> <sourceObjective> […execute]/execute unless score <target> <targetObjective> = <source> <sourceObjective> […execute]/execute unless score <target> <targetObjective> > <source> <sourceObjective> […execute]/execute unless score <target> <targetObjective> >= <source> <sourceObjective> […execute]/execute unless score <target> <targetObjective> matches <range> […execute]/execute unless slots block <source> <slots> […execute]/execute unless slots entity <source> <slots> […execute]/execute unless stopwatch <id> <range> […execute]/execute as <targets> → execute …/execute at <targets> → execute …/execute positioned <pos> → execute …/execute in <dimension> → execute …/execute if block <pos> <block> [...execute]/execute if entity <entities> [...execute]/execute if score <target> <targetObjective> matches <range> [...execute]/execute if items entity <source> <slots> <item_predicate> [...execute]| Argument | Type | What it means |
|---|---|---|
<axes> | axes | Any combination of the x, y, and z axes, such as xz, used to align coordinates. |
<anchor> | anchor | Sets whether local coordinates and facing checks start from the entity's eyes or feet. |
<targets> | target selector | A player name, a UUID or a target selector such as @p, @a, @e or @s. |
<pos> | position | Three coordinates x y z that may have decimals; ~ and ^ work too. |
<pos> | block position | Three coordinates x y z. Use ~ for relative or ^ for local coordinates. |
<biome> | entry or #tag worldgen/biome | A biome entry ID or #tag from worldgen/biome to test at a given position. |
<block> | block test | A block ID or #tag to match against the world, optionally including block states. |
<start> | block position | Three coordinates x y z. Use ~ for relative or ^ for local coordinates. |
<end> | block position | Three coordinates x y z. Use ~ for relative or ^ for local coordinates. |
<destination> | block position | Three coordinates x y z. Use ~ for relative or ^ for local coordinates. |
<source> | block position | Depending on the subcommand, a block position, a single target selector, a score holder, or a resource ID. |
<path> | NBT path | An NBT path pointing to a specific piece of data, such as Inventory[0].id. |
<source> | target selector one target | Depending on the subcommand, a block position, a single target selector, a score holder, or a resource ID. |
<source> | resource ID | Depending on the subcommand, a block position, a single target selector, a score holder, or a resource ID. |
<dimension> | dimension | The dimension ID to check or switch to, such as overworld, the_nether, the_end, or a custom dimension. |
<entities> | target selector | A player name, a UUID or a target selector such as @p, @a, @e or @s. |
<name> | function | A function or #function tag from a data pack. |
<slots> | slot source | The inventory slot source to inspect on a block or entity. |
<item_predicate> | item test | An item ID, a #tag, or * to match any items in the chosen slots. |
<predicate> | predicate | A predicate ID or inline predicate. |
<target> | score holder one target | A player, selector or fake player name; * means everyone tracked. |
<targetObjective> | objective | The name of a scoreboard objective. |
<source> | score holder one target | Depending on the subcommand, a block position, a single target selector, a score holder, or a resource ID. |
<sourceObjective> | objective | The name of a scoreboard objective. |
<range> | number range | A single number or range such as 5, 1..10, ..3, 4.., or a decimal range like 0.5..2. |
<id> | resource ID | A namespaced ID such as minecraft:stone. |
<range> | number range | A single number or range such as 5, 1..10, ..3, 4.., or a decimal range like 0.5..2. |
<heightmap> | heightmap | Which height map to use, e.g. world_surface. |
<rot> | rotation | Yaw then pitch, for example 90 0. |
<target> | block position | Three coordinates x y z. Use ~ for relative or ^ for local coordinates. |
<scale> | decimal number | A number that can have decimals, such as 1.25. |
<target> | target selector one target | A player name, a UUID or a target selector such as @p, @a, @e or @s. |
<targets> | score holder | A player, selector or fake player name; * means everyone tracked. |
<objective> | objective | The name of a scoreboard objective. |
<target> | resource ID | A namespaced ID such as minecraft:stone. |
<entity> | registry entry entity type | An entry of a registry, e.g. an effect, enchantment or entity type. |
/execute if entity @pChecks whether there is at least one player currently in the world.
/execute if block 10 64 -20 minecraft:stoneTests if the block located at coordinates 10, 64, -20 is stone.
/execute at @a if biome ~ ~ ~ minecraft:plainsMoves the check to every player's location and tests if they are standing in a plains biome.
/execute in the_nether if loaded 0 80 0Switches context to the Nether and checks if the chunk containing 0, 80, 0 is currently loaded.
/execute as @e on vehicle if entity @sSelects all entities, switches context to whatever vehicle they are riding, and verifies the vehicle exists.
/execute if score @s points matches 1..10Checks if the current executor has a score between 1 and 10 in the points objective.
/execute positioned 100.5 70.0 -50.5 align xz facing 120 70 -50 if dimension overworldMoves to decimal coordinates, snaps to the block grid on the X and Z axes, faces a target coordinate, and verifies the dimension is the Overworld.
/execute anchored eyes facing entity @r feet if data storage minecraft:custom_data ActivePathSets the local anchor to the eyes, turns toward a random player's feet, and checks if a specific NBT path exists in command storage.
Measured from the game files of every Java release from 1.13 to 26.3.
+ /execute if data block <source> <path> […execute]+ /execute if items block <source> <slots> <item_predicate> […execute]+ /execute if items entity <source> <slots> <item_predicate> […execute]+ /execute if slots block <source> <slots> […execute]+ /execute if slots entity <source> <slots> […execute]+ /execute store result block <target> <path> byte <scale> …execute− /execute if data block <sourcePos> <path> […execute]− /execute if items block <pos> <slots> <item_predicate> […execute]− /execute if items entity <entities> <slots> <item_predicate> […execute]− /execute store result block <targetPos> <path> byte <scale> …execute− /execute store result block <targetPos> <path> double <scale> …execute− /execute store result block <targetPos> <path> float <scale> …executeand 28 more+ /execute if stopwatch <id> <range> […execute]+ /execute unless stopwatch <id> <range> […execute]+ /execute if items block <pos> <slots> <item_predicate> […execute]+ /execute if items entity <entities> <slots> <item_predicate> […execute]+ /execute unless items block <pos> <slots> <item_predicate> […execute]+ /execute unless items entity <entities> <slots> <item_predicate> […execute]+ /execute if function <name> …execute+ /execute unless function <name> …execute+ /execute if dimension <dimension> […execute]+ /execute if loaded <pos> […execute]+ /execute on attacker …execute+ /execute on controller …execute+ /execute on leasher …execute+ /execute on origin …executeand 8 more+ /execute if biome <pos> <biome> […execute]+ /execute unless biome <pos> <biome> […execute]+ /execute if data storage <source> <path> […execute]+ /execute if predicate <predicate> […execute]+ /execute store result storage <target> <path> byte <scale> …execute+ /execute store result storage <target> <path> double <scale> …execute+ /execute store result storage <target> <path> float <scale> …execute+ /execute store result storage <target> <path> int <scale> …executeand 10 more+ /execute if data block <sourcePos> <path> […execute]+ /execute if data entity <source> <path> […execute]+ /execute store result block <targetPos> <path> byte <scale> …execute+ /execute store result block <targetPos> <path> double <scale> …execute+ /execute store result block <targetPos> <path> float <scale> …execute+ /execute store result block <targetPos> <path> int <scale> …execute− /execute store result block <pos> <path> byte <scale> …execute− /execute store result block <pos> <path> double <scale> …execute− /execute store result block <pos> <path> float <scale> …execute− /execute store result block <pos> <path> int <scale> …execute− /execute store result block <pos> <path> long <scale> …execute− /execute store result block <pos> <path> short <scale> …executeand 16 more+ /execute in <dimension> …execute− /execute in overworld …execute− /execute in the_end …execute− /execute in the_nether …executeBedrock Edition also includes the /execute command, using chained syntax forms such as /execute as <origin: target>, /execute at <origin: target>, /execute in <dimension: Dimension>, and /execute positioned <position: x y z> followed by the next chained option.
The as subcommand changes the entity executing the command (which changes who @s refers to), while at moves the coordinate position, rotation, and dimension to match the target without changing who the executor is.
Since version 1.20.5 (and updated in 26.3 to use a single <source>), you can use /execute if items entity <source> <slots> <item_predicate> to check specific slots for an item ID, item tag, or * for any item.
You need permission level 2, which is granted to server operators, command blocks, functions, and single-player worlds with cheats turned on.
/bossbar/data/function/random/return/schedule/scoreboard/tag/team/trigger