How To Use The Execute Command In Minecraft
Maybe your like
This Minecraft tutorial explains how to use the /execute command with screenshots and step-by-step instructions.
The /execute command is one of most complex commands in Minecraft. In most cases, you will chain multiple /execute commands together making the command a bit more difficult to understand. Let's explore how to use this cheat (game command).
Supported Platforms
The /execute command is available in the following versions of Minecraft:
| Platform | Supported (Version*) |
|---|---|
| Yes (1.8) | |
| Yes (0.16.0) | |
| No | |
| Yes (1.2) | |
| No | |
| Yes (1.14.0) | |
| No | |
| Yes (1.5.0) | |
| Yes (0.16.0) | |
| Yes |
* The version that it was added or removed, if applicable. NOTE: Pocket Edition (PE), Xbox One, PS4, Nintendo Switch, and Windows 10 Edition are now called Bedrock Edition. We will continue to show them individually for version history.
Requirements
To run game commands in Minecraft, you have to turn cheats on in your world.
Execute Command
- Java
- PE
- Xbox
- PS
- Nintendo
- Win10
- Edu
Execute Command in Minecraft Java Edition (PC/Mac)
In Minecraft Java Edition (PC/Mac) 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20, there are different syntaxes for the /execute command.
To align the block grid based on the specified axes and then run a second /execute command based on the aligned position:
/execute align <axes> <secondExecuteCommand>To anchor the local coordinate origin to either the eyes or the feet of the entity running the command and then run a second /execute command:
/execute anchored <eyes¦feet> <secondExecuteCommand>To run a second /execute command on behalf of an entity:
/execute as <targets> <secondExecuteCommand>To run a second /execute command using the position, dimension (ie: Overworld, Nether, End) and rotation of the target entity (without changing the entity that is running the command):
/execute at <targets> <secondExecuteCommand>To run a second /execute command that uses an execution point that faces the target entity's eyes or feet:
/execute facing entity <targets> <eyes¦feet> <secondExecuteCommand>To run a second /execute command that uses an execution point that faces a specific coordinate:
/execute facing <pos> <secondExecuteCommand>To run a second /execute command if a block at specified coordinate matches the given Minecraft ID name:
/execute if block <pos> <blockID> <secondExecuteCommand>To run a second /execute command if the blocks in the region from <start> to <end> matches the <destination>:
/execute if blocks <start> <end> <destination> <all¦masked> <secondExecuteCommand>To run a second /execute command if a block at a specific coordinate has data for the NBT tag specified by <path>:
/execute if data block <pos> <path> <secondExecuteCommand>To run a second /execute command if a targeted entity has data for the NBT tag specified by <path>:
/execute if data entity <target> <path> <secondExecuteCommand>To run a second /execute command if a targeted entity exists:
/execute if entity <targets> <secondExecuteCommand>To run a second /execute command if a targeted entity has a score (for a targeted objective) that matches a range:
/execute if score <target> <targetObjective> matches <range> <secondExecuteCommand>To run a second /execute command if a targeted entity has a score (for a targeted objective) that meets a criteria when comparing to a source objective. The comparison of the two objectives can be based on: less than (<), less than equals (<=), equals (=), greater than (>), or greater than equals (>=):
/execute if score <target> <targetObjective> (<¦<=¦=¦>¦>=) <source> <sourceObjective> <secondExecuteCommand>To run a second /execute command as if the entity running the command is in the specified dimension:
/execute in <minecraft:overworld¦minecraft:the_end¦minecraft:the_nether> <secondExecuteCommand>To run a second /execute command using the target's position as the current position:
/execute positioned as <targets> <secondExecuteCommand>To run a second /execute command using a specified coordinate as the current position:
/execute positioned <pos> <secondExecuteCommand>To run a second /execute command using the rotation of the target:
/execute rotated as <targets> <secondExecuteCommand>To run any game command (such as /give, /summon, /particle commands):
/execute run <gameCommand>To store the result/success of a second /execute command in a block at a specified coordinate:
/execute store <result¦success> block <pos> <path> <byte¦double¦float¦int¦long¦short> <scale> <secondExecuteCommand>To store the result/success of a second /execute command in a bossbar:
/execute store <result¦success> bossbar <id> <max¦value> <secondExecuteCommand>To store the result/success of a second /execute command in a target entity's NBT tag as specified by <path>:
/execute store <result¦success> entity <target> <path> <byte¦double¦float¦int¦long¦short> <scale> <secondExecuteCommand>To store the result/success of a second /execute command in the score of a target entity's objective:
/execute store <result¦success> score <target> <objective> <secondExecuteCommand>To store the result/success of a second /execute command in the score of a target entity's objective:
/execute store <result¦success> score <target> <objective> <secondExecuteCommand>To run a second /execute command unless a block at specified coordinate matches the given Minecraft ID name:
/execute unless block <pos> <blockID> <secondExecuteCommand>To run a second /execute command unless the blocks in the region from <start> to <end> matches the <destination>:
/execute unless blocks <start> <end> <destination> <all¦masked> <secondExecuteCommand>To run a second /execute command unless a block at a specific coordinate has data for the NBT tag specified by <path>:
/execute unless data block <pos> <path> <secondExecuteCommand>To run a second /execute command unless a targeted entity has data for the NBT tag specified by <path>:
/execute unless data entity <target> <path> <secondExecuteCommand>To run a second /execute command unless a targeted entity exists:
/execute unless entity <targets> <secondExecuteCommand>To run a second /execute command unless a targeted entity has a score (for a targeted objective) that matches a range:
/execute unless score <target> <targetObjective> matches <range> <secondExecuteCommand>To run a second /execute command unless a targeted entity has a score (for a targeted objective) that meets a criteria when comparing to a source objective. The comparison of the two objectives can be based on: less than (<), less than equals (<=), equals (=), greater than (>), or greater than equals (>=):
/execute unless score <target> <targetObjective> (<¦<=¦=¦>¦>=) <source> <sourceObjective> <secondExecuteCommand>In Minecraft Java Edition (PC/Mac) 1.11 and 1.12, there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <entity> <x> <y> <z> <command>To execute a command on behalf of the entity, only if a specific block is detected at <x1> <y1> <z1>:
/execute <entity> <x> <y> <z> detect <x1> <y1> <z1> <block> <data> <command>Definitions
- secondExecuteCommand is an /execute command that is chained onto the current command without specifying the /execute keyword.
- axes are the axes to align. It can be any combination of xyz such as x, y, z, xz, xy, yz, xyz.
- target or targets is the name of the player (or a target selector).
- entity is the name of a player (or a target selector) who will run the command.
- x y z is the position to run the command. If a relative value (~) is provided, then the position is relative to the entity.
- x1 y1 z1 is the position to detect the block.
- block is name of the block to detect at position x1 y1 z1. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at position x1 y1 z1. If detected, then the command will be executed. (See Minecraft Data Values)
- command or gameCommand is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Execute Command in Minecraft Pocket Edition (PE)
In Minecraft Pocket Edition (PE), there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <origin> <position> <command>To execute a command on behalf of the entity, only if a specific block is detected at <detectPos>:
/execute <origin> <position> detect <detectPos> <block> <data> <command>Definitions
- origin is the name of a player (or a target selector) who will run the command.
- position is the x y z coordinate to run the command from. If a relative value (~) is provided, then the position is relative to the entity.
- detectPos is the x y z coordinate to detect the block.
- block is name of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Data Values)
- command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Execute Command in Minecraft Xbox One Edition
In Minecraft Xbox One Edition, there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <origin> <position> <command>To execute a command on behalf of the entity, only if a specific block is detected at <detectPos>:
/execute <origin> <position> detect <detectPos> <block> <data> <command>Definitions
- origin is the name of a player (or a target selector) who will run the command.
- position is the x y z coordinate to run the command from. If a relative value (~) is provided, then the position is relative to the entity.
- detectPos is the x y z coordinate to detect the block.
- block is name of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Data Values)
- command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Execute Command in Minecraft PS4 Edition
In Minecraft PS4 Edition, there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <origin> <position> <command>To execute a command on behalf of the entity, only if a specific block is detected at <detectPos>:
/execute <origin> <position> detect <detectPos> <block> <data> <command>Definitions
- origin is the name of a player (or a target selector) who will run the command.
- position is the x y z coordinate to run the command from. If a relative value (~) is provided, then the position is relative to the entity.
- detectPos is the x y z coordinate to detect the block.
- block is name of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Data Values)
- command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Execute Command in Minecraft Nintendo Switch Edition
In Minecraft Nintendo Switch Edition, there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <origin> <position> <command>To execute a command on behalf of the entity, only if a specific block is detected at <detectPos>:
/execute <origin> <position> detect <detectPos> <block> <data> <command>Definitions
- origin is the name of a player (or a target selector) who will run the command.
- position is the x y z coordinate to run the command from. If a relative value (~) is provided, then the position is relative to the entity.
- detectPos is the x y z coordinate to detect the block.
- block is name of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Data Values)
- command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Execute Command in Minecraft Windows 10 Edition
In Minecraft Windows 10 Edition, there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <origin> <position> <command>To execute a command on behalf of the entity, only if a specific block is detected at <detectPos>:
/execute <origin> <position> detect <detectPos> <block> <data> <command>Definitions
- origin is the name of a player (or a target selector) who will run the command.
- position is the x y z coordinate to run the command from. If a relative value (~) is provided, then the position is relative to the entity.
- detectPos is the x y z coordinate to detect the block.
- block is name of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Data Values)
- command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Execute Command in Minecraft Education Edition
In Minecraft Education Edition, there are 2 syntaxes for the /execute command.
To execute a command on behalf of an entity:
/execute <origin> <position> <command>To execute a command on behalf of the entity, only if a specific block is detected at <detectPos>:
/execute <origin> <position> detect <detectPos> <block> <data> <command>Definitions
- origin is the name of a player (or a target selector) who will run the command.
- position is the x y z coordinate to run the command from. If a relative value (~) is provided, then the position is relative to the entity.
- detectPos is the x y z coordinate to detect the block.
- block is name of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Item Names)
- data is the data value of the block to detect at detectPos. If detected, then the command will be executed. (See Minecraft Data Values)
- command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.
Examples
- Java
- PE
- Xbox
- PS
- Nintendo
- Win10
- Edu
Example in Java Edition (PC/Mac) 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20
To first align the current xyz position in the block grid and then summon a cat if the entity running the command is within 5 blocks of the coordinate (229,70,92):
/execute align xyz if entity @s[x=229,y=70,z=92,distance=..5] run summon catTo anchor to eye level and then display the flame particle that is 1 block in front of the entity executing the command:
/execute anchored eyes run particle minecraft:flame ^ ^ ^1 0 0 0 0 10To give all players 8 golden apples:
/execute as @a run give @p golden_apple 8To summon a lightning bolt at all creepers:
/execute at @e[type=creeper] run summon lightning_boltTo teleport all players to the coordinates (8, 64, 22):
/execute as @a run tp @p 8 64 22Example in Java Edition (PC/Mac) 1.11 and 1.12
To give a golden apple to all players in Java Edition (PC/Mac) 1.11 and 1.12:
/execute @a ~ ~ ~ /give @p golden_appleTo give 64 golden apples to all players:
/execute @a ~ ~ ~ /give @p golden_apple 64To teleport all players to the coordinates (8, 64, 22):
/execute @a ~ ~ ~ /tp @p 8 64 22To summon a lightning bolt at all creepers:
/execute @e[type=creeper] ~ ~ ~ /summon lightning_boltExample in Java Edition (PC/Mac) 1.10
To summon a lightning bolt at all creepers in Java Edition (PC/Mac) 1.10:
/execute @e[type=Creeper] ~ ~ ~ /summon LightningBoltExample in Pocket Edition (PE)
To give an enchanted golden apple to all players in Minecraft PE:
/execute @a ~ ~ ~ give @p appleenchantedTo give 64 enchanted golden apples to all players:
/execute @a ~ ~ ~ give @p appleenchanted 64To teleport all players to the coordinates (8, 64, 22):
/execute @a ~ ~ ~ tp 8 64 22Example in Xbox One Edition
To give an iron sword to all players in Minecraft Xbox One Edition:
/execute @a ~ ~ ~ give @p iron_swordTo give 3 coal blocks to all players:
/execute @a ~ ~ ~ give @p coal_block 3To teleport all players to the coordinates (-1, 62, 80):
/execute @a ~ ~ ~ tp -1 62 80Example in PS4 Edition
To give a trident to all players in Minecraft PS4 Edition:
/execute @a ~ ~ ~ give @p tridentTo give 64 golden apples to all players:
/execute @a ~ ~ ~ give @p golden_apple 64To teleport all players to the coordinates (12, 68, -40):
/execute @a ~ ~ ~ tp 12 68 -40Example in Nintendo Switch Edition
To give a fishing rod to all players in Minecraft Nintendo Switch Edition:
/execute @a ~ ~ ~ give @p fishing_rodTo give 64 golden apples to all players:
/execute @a ~ ~ ~ give @p golden_apple 64To teleport all players to the coordinates (16, 70, -50):
/execute @a ~ ~ ~ tp 16 70 -50Example in Windows 10 Edition
To give a diamond sword to all players in Windows 10 Edition:
/execute @a ~ ~ ~ give @p diamond_swordTo give 5 diamond swords to all players:
/execute @a ~ ~ ~ give @p diamond_sword 5To teleport all players to the coordinates (12, 65, 34):
/execute @a ~ ~ ~ tp 12 65 34Example in Education Edition
To give a golden apple to all players in Minecraft Education Edition:
/execute @a ~ ~ ~ give @p golden_appleTo give 64 golden apples to all players:
/execute @a ~ ~ ~ give @p golden_apple 64To teleport all players to the coordinates (20, 65, 32):
/execute @a ~ ~ ~ tp 20 65 32How to Enter the Command
1. Open the Chat Window
The easiest way to run a command in Minecraft is within the chat window. The game control to open the chat window depends on the version of Minecraft:
- For Java Edition (PC/Mac), press the T key to open the chat window.
- For Pocket Edition (PE), tap on the chat button
at the top of the screen. - For Xbox One, press the D-Pad (right)
on the controller. - For PS4, press the D-Pad (right)
on the controller. - For Nintendo Switch, press the right arrow button
on the controller. - For Windows 10 Edition, press the T key to open the chat window.
- For Education Edition, press the T key to open the chat window.
2. Type the Command
We will cover examples of how to use the /execute command that chain multiple execute commands together.
Summon a Cat if within 5 blocks of a Specific Coordinate
In this example, we are going to first align the current xyz position in the block grid and then summon a cat if the entity running the command is within 5 blocks of the coordinate (229,70,92) with the following command:
/execute align xyz if entity @s[x=229,y=70,z=92,distance=..5] run summon catType the command in the chat window. As you are typing, you will see the command appear in the lower left corner of the game window. Press the Enter key to run the command.

Once the cheat has been entered, the cat will be summoned ONLY IF you are within 5 blocks of the xyz coordinate (229,70,92).

You will see the message "Summoned new Cat" appear in the lower left corner to indicate that the summon was successfully summoned. If the player was NOT within 5 blocks of the coordinate (229,70,92), the /execute command would do nothing and NOT summon a cat.
Display a Particle directly in front of an Entity at Eye Level
In this example, we are going to anchor to eye level and then display the flame particle that is 1 block in front of the entity executing the command with the following command:
/execute anchored eyes run particle minecraft:flame ^ ^ ^1 0 0 0 0 10Type the command in the chat window and press the Enter key to run the command.

Once the cheat has been entered, the flame particle will appear directly 1 block in front of the entity running the command.

You will see the message "Displaying particle minecraft:flame" appear in the lower left corner of the game window to indicate that the flame particle has been displayed. With this command, no matter where the entity is looking, the flame particle will appear directly in front of the entity at eye-level.
Give all players 8 Golden Apples
In this example, we are going to give all players 8 golden apples with the following command:
/execute as @a run give @p golden_apple 8Type the command in the chat window and press the Enter key to run the command.

Once the cheat has been entered, 8 golden apples will be given to each player.

You will see the message "Gave 8 [Golden Apple] to DigMinecraft" appear in the lower left corner of the game window to indicate that the golden apples were given to the players. Since we are running the /execute command on behalf of @a, all players will be given 8 golden apples.
As you can see, the possibilities for the /execute command are endless. Give it a try and see what amazing commands you can create.
Congratulations, you have learned how to use the /execute command in Minecraft.
Tag » How To Use Execute As Command In Minecraft
-
Commands/execute - Minecraft Wiki - Fandom
-
Minecraft Execute Command [1.19] Tutorial - YouTube
-
How To Use /execute Command In Minecraft 1.17 (Java Edition, PC)
-
New Execute Command Support In Minecraft Version 1.19.10
-
What Does The /execute Command Do In Minecraft: Java Edition?
-
How To Use The /execute Command - Minecraft: Java Edition
-
Useful Guide For Minecraft Bedrock Commands And MCFunction
-
Anyone Know How To Use The New /execute Command? - Reddit
-
Why Do I Have To Put At @s In A Execute Command? - Arqade
-
How To Use Execute Command In Minecraft - Bilibili
-
How To Use The Execute Command (Beginer Tutorial) For Java And ...
-
How To Use The Execute Command In Minecraft - Info Toast
-
In Minecraft Execute Command At Entities Around An Arrow
-
Essential Commands - Minecraft: Education Edition Support