/execute Command in Minecraft Java Edition

Run Commands from Any Context or Condition

Java EditionLogic & ScoreboardPermission: Level 2Bedrock version →

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.

Syntax (Java 26.3, 110 forms)

  1. /execute align <axes> → execute …
  2. /execute anchored <anchor> → execute …
  3. /execute as <targets> → execute …
  4. /execute at <targets> → execute …
  5. /execute facing <pos> → execute …
  6. /execute facing entity <targets> <anchor> → execute …
  7. /execute if biome <pos> <biome> […execute]
  8. /execute if block <pos> <block> […execute]
  9. /execute if blocks <start> <end> <destination> all […execute]
  10. /execute if blocks <start> <end> <destination> masked […execute]
  11. /execute if data block <source> <path> […execute]
  12. /execute if data entity <source> <path> […execute]
  13. /execute if data storage <source> <path> […execute]
  14. /execute if dimension <dimension> […execute]
  15. /execute if entity <entities> […execute]
  16. /execute if function <name> → execute …
  17. /execute if items block <source> <slots> <item_predicate> […execute]
  18. /execute if items entity <source> <slots> <item_predicate> […execute]
  19. /execute if loaded <pos> […execute]
  20. /execute if predicate <predicate> […execute]
  21. /execute if score <target> <targetObjective> < <source> <sourceObjective> […execute]
  22. /execute if score <target> <targetObjective> <= <source> <sourceObjective> […execute]
  23. /execute if score <target> <targetObjective> = <source> <sourceObjective> […execute]
  24. /execute if score <target> <targetObjective> > <source> <sourceObjective> […execute]
  25. /execute if score <target> <targetObjective> >= <source> <sourceObjective> […execute]
  26. /execute if score <target> <targetObjective> matches <range> […execute]
  27. /execute if slots block <source> <slots> […execute]
  28. /execute if slots entity <source> <slots> […execute]
  29. /execute if stopwatch <id> <range> […execute]
  30. /execute in <dimension> → execute …
  31. /execute on attacker → execute …
  32. /execute on controller → execute …
  33. /execute on leasher → execute …
  34. /execute on origin → execute …
  35. /execute on owner → execute …
  36. /execute on passengers → execute …
  37. /execute on target → execute …
  38. /execute on vehicle → execute …
  39. /execute positioned <pos> → execute …
  40. /execute positioned as <targets> → execute …
  41. /execute positioned over <heightmap> → execute …
  42. /execute rotated <rot> → execute …
  43. /execute rotated as <targets> → execute …
  44. /execute run <any command>
  45. /execute store result block <target> <path> byte <scale> → execute …
  46. /execute store result block <target> <path> double <scale> → execute …
  47. /execute store result block <target> <path> float <scale> → execute …
  48. /execute store result block <target> <path> int <scale> → execute …
  49. /execute store result block <target> <path> long <scale> → execute …
  50. /execute store result block <target> <path> short <scale> → execute …
  51. /execute store result bossbar <id> max → execute …
  52. /execute store result bossbar <id> value → execute …
  53. /execute store result entity <target> <path> byte <scale> → execute …
  54. /execute store result entity <target> <path> double <scale> → execute …
  55. /execute store result entity <target> <path> float <scale> → execute …
  56. /execute store result entity <target> <path> int <scale> → execute …
  57. /execute store result entity <target> <path> long <scale> → execute …
  58. /execute store result entity <target> <path> short <scale> → execute …
  59. /execute store result score <targets> <objective> → execute …
  60. /execute store result storage <target> <path> byte <scale> → execute …
  61. /execute store result storage <target> <path> double <scale> → execute …
  62. /execute store result storage <target> <path> float <scale> → execute …
  63. /execute store result storage <target> <path> int <scale> → execute …
  64. /execute store result storage <target> <path> long <scale> → execute …
  65. /execute store result storage <target> <path> short <scale> → execute …
  66. /execute store success block <target> <path> byte <scale> → execute …
  67. /execute store success block <target> <path> double <scale> → execute …
  68. /execute store success block <target> <path> float <scale> → execute …
  69. /execute store success block <target> <path> int <scale> → execute …
  70. /execute store success block <target> <path> long <scale> → execute …
  71. /execute store success block <target> <path> short <scale> → execute …
  72. /execute store success bossbar <id> max → execute …
  73. /execute store success bossbar <id> value → execute …
  74. /execute store success entity <target> <path> byte <scale> → execute …
  75. /execute store success entity <target> <path> double <scale> → execute …
  76. /execute store success entity <target> <path> float <scale> → execute …
  77. /execute store success entity <target> <path> int <scale> → execute …
  78. /execute store success entity <target> <path> long <scale> → execute …
  79. /execute store success entity <target> <path> short <scale> → execute …
  80. /execute store success score <targets> <objective> → execute …
  81. /execute store success storage <target> <path> byte <scale> → execute …
  82. /execute store success storage <target> <path> double <scale> → execute …
  83. /execute store success storage <target> <path> float <scale> → execute …
  84. /execute store success storage <target> <path> int <scale> → execute …
  85. /execute store success storage <target> <path> long <scale> → execute …
  86. /execute store success storage <target> <path> short <scale> → execute …
  87. /execute summon <entity> → execute …
  88. /execute unless biome <pos> <biome> […execute]
  89. /execute unless block <pos> <block> […execute]
  90. /execute unless blocks <start> <end> <destination> all […execute]
  91. /execute unless blocks <start> <end> <destination> masked […execute]
  92. /execute unless data block <source> <path> […execute]
  93. /execute unless data entity <source> <path> […execute]
  94. /execute unless data storage <source> <path> […execute]
  95. /execute unless dimension <dimension> […execute]
  96. /execute unless entity <entities> […execute]
  97. /execute unless function <name> → execute …
  98. /execute unless items block <source> <slots> <item_predicate> […execute]
  99. /execute unless items entity <source> <slots> <item_predicate> […execute]
  100. /execute unless loaded <pos> […execute]
  101. /execute unless predicate <predicate> […execute]
  102. /execute unless score <target> <targetObjective> < <source> <sourceObjective> […execute]
  103. /execute unless score <target> <targetObjective> <= <source> <sourceObjective> […execute]
  104. /execute unless score <target> <targetObjective> = <source> <sourceObjective> […execute]
  105. /execute unless score <target> <targetObjective> > <source> <sourceObjective> […execute]
  106. /execute unless score <target> <targetObjective> >= <source> <sourceObjective> […execute]
  107. /execute unless score <target> <targetObjective> matches <range> […execute]
  108. /execute unless slots block <source> <slots> […execute]
  109. /execute unless slots entity <source> <slots> […execute]
  110. /execute unless stopwatch <id> <range> […execute]

The forms you will use most

/execute as <targets> → execute …
Changes who is executing the command to the chosen players or entities without changing the current position.
/execute at <targets> → execute …
Moves the execution position, rotation, and dimension to match the chosen targets without changing who runs the command.
/execute positioned <pos> → execute …
Moves the execution point to the exact x, y, and z coordinates you specify.
/execute in <dimension> → execute …
Switches the execution context to the Overworld, the Nether, the End, or a custom dimension.
/execute if block <pos> <block> [...execute]
Tests if a block at a specific coordinate matches a block ID or tag before continuing.
/execute if entity <entities> [...execute]
Checks whether at least one entity matching the target selector exists in the world.
/execute if score <target> <targetObjective> matches <range> [...execute]
Checks if a target's scoreboard value falls within a specific number range.
/execute if items entity <source> <slots> <item_predicate> [...execute]
Tests whether an entity has a matching item inside the specified inventory slots.

Arguments

ArgumentTypeWhat it means
<axes>axesAny combination of the x, y, and z axes, such as xz, used to align coordinates.
<anchor>anchorSets whether local coordinates and facing checks start from the entity's eyes or feet.
<targets>target selectorA player name, a UUID or a target selector such as @p, @a, @e or @s.
<pos>positionThree coordinates x y z that may have decimals; ~ and ^ work too.
<pos>block positionThree 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 testA block ID or #tag to match against the world, optionally including block states.
<start>block positionThree coordinates x y z. Use ~ for relative or ^ for local coordinates.
<end>block positionThree coordinates x y z. Use ~ for relative or ^ for local coordinates.
<destination>block positionThree coordinates x y z. Use ~ for relative or ^ for local coordinates.
<source>block positionDepending on the subcommand, a block position, a single target selector, a score holder, or a resource ID.
<path>NBT pathAn 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 IDDepending on the subcommand, a block position, a single target selector, a score holder, or a resource ID.
<dimension>dimensionThe dimension ID to check or switch to, such as overworld, the_nether, the_end, or a custom dimension.
<entities>target selectorA player name, a UUID or a target selector such as @p, @a, @e or @s.
<name>functionA function or #function tag from a data pack.
<slots>slot sourceThe inventory slot source to inspect on a block or entity.
<item_predicate>item testAn item ID, a #tag, or * to match any items in the chosen slots.
<predicate>predicateA predicate ID or inline predicate.
<target>score holder
one target
A player, selector or fake player name; * means everyone tracked.
<targetObjective>objectiveThe 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>objectiveThe name of a scoreboard objective.
<range>number rangeA single number or range such as 5, 1..10, ..3, 4.., or a decimal range like 0.5..2.
<id>resource IDA namespaced ID such as minecraft:stone.
<range>number rangeA single number or range such as 5, 1..10, ..3, 4.., or a decimal range like 0.5..2.
<heightmap>heightmapWhich height map to use, e.g. world_surface.
<rot>rotationYaw then pitch, for example 90 0.
<target>block positionThree coordinates x y z. Use ~ for relative or ^ for local coordinates.
<scale>decimal numberA 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 holderA player, selector or fake player name; * means everyone tracked.
<objective>objectiveThe name of a scoreboard objective.
<target>resource IDA namespaced ID such as minecraft:stone.
<entity>registry entry
entity type
An entry of a registry, e.g. an effect, enchantment or entity type.

Examples

Version history

Measured from the game files of every Java release from 1.13 to 26.3.

  1. 26.3 Syntax changed.
    + /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
  2. 1.21.11 Syntax changed.
    + /execute if stopwatch <id> <range> […execute]+ /execute unless stopwatch <id> <range> […execute]
  3. 1.20.5 Syntax changed.
    + /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]
  4. 1.20.3 Syntax changed.
    + /execute if function <name> …execute+ /execute unless function <name> …execute
  5. 1.19.4 Syntax changed.
    + /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
  6. 1.19.3 Syntax changed.
    + /execute if biome <pos> <biome> […execute]+ /execute unless biome <pos> <biome> […execute]
  7. 1.15 Syntax changed.
    + /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
  8. 1.14 Syntax changed.
    + /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
  9. 1.13.1 Syntax changed.
    + /execute in <dimension> …execute− /execute in overworld …execute− /execute in the_end …execute− /execute in the_nether …execute
  10. 1.13 Already in the game in 1.13, the oldest Java version we track.

Tips

Common mistakes

Java vs Bedrock

Bedrock 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.

See /execute in Bedrock Edition →

FAQ

What is the difference between execute as and execute at?

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.

How do I check if a player has an item in their inventory?

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.

What permission level is needed to use /execute?

You need permission level 2, which is granted to server operators, command blocks, functions, and single-player worlds with cheats turned on.

Related commands

/bossbar/data/function/random/return/schedule/scoreboard/tag/team/trigger