How to Use the Execute Command in Minecraft

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:

PlatformSupported (Version*)
Java Edition (PC/Mac) Java Edition (PC/Mac)Yes (1.8)
Pocket Edition (PE) Pocket Edition (PE)Yes (0.16.0)
Xbox 360 Xbox 360No
Xbox One Xbox OneYes (1.2)
PS3 PS3No
PS4 PS4Yes (1.14.0)
Wii U Wii UNo
Nintendo Switch Nintendo SwitchYes (1.5.0)
Windows 10 Edition Windows 10 EditionYes (0.16.0)
Education Edition Education EditionYes

* 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

TIP: Read our tutorial called Understanding the Coordinate System to learn about the XYZ coordinates in Minecraft and how to find your current coordinates.

Examples

How 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 help command at the top of the screen.
  • For Xbox One, press the D-Pad (right) xbox one on the controller.
  • For PS4, press the D-Pad (right) ps4 on the controller.
  • For Nintendo Switch, press the right arrow button nintendo switch 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 cat

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

execute 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).

completed execute command

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 10

Type the command in the chat window and press the Enter key to run the command.

execute command

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

completed execute 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 8

Type the command in the chat window and press the Enter key to run the command.

execute command

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

completed execute command

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.