Minecraft · Guide

Minecraft Execute Command Explained with Examples

The Minecraft execute command explained: as, at, if, unless and run, with examples for Java and Bedrock.

Game Respawned Editorial TeamUpdated November 5, 2026

The execute command runs another command with a changed executor, position, dimension or condition. In both editions the syntax is /execute as <targets> at @s run <command>. Use as to change who runs it, at to change where, if or unless to add a condition, and run to say what happens.

Advanced Java Bedrock

The idea

A plain command runs from one place, as one executor. Execute changes that. You chain subcommands, each one adjusting the context, and finish with run and the real command. Read it left to right like a sentence: execute as every player, at their position, if they stand on gold, run give.

Bedrock has used this Java-style syntax since 1.19.50, so the examples below work on both editions unless marked.

Subcommands

SubcommandWhat it does
as <targets>Runs the rest as each target. Inside, @s is that target.
at <targets>Runs the rest at each target position and rotation. Does not change who @s is.
positioned <x y z>Sets the position by hand.
in <dimension>Runs in the overworld, the nether or the end.
if / unless blockContinue only if a block is (or is not) at a position.
if / unless entityContinue only if a selector matches something.
if / unless scoreCompare scoreboard values.
run <command>The command that finally runs.

Java has more, such as store, align, anchored, facing, rotated and summon. Build the common ones with our execute command builder.

as and at are different as changes who runs the command. at changes where it runs. To act on a player at their location you almost always need both: execute as @a at @s run ...

Examples to copy

Run something at every player

execute as @a at @s run particle heart ~ ~2 ~

Reward a player standing on a gold block

execute as @a at @s if block ~ ~-1 ~ gold_block run give @s apple

Do something only if a zombie is near

execute if entity @e[type=zombie,distance=..10] run say Zombie nearby!

Run in another dimension

execute in the_nether run setblock 0 100 0 glowstone

Stop a command when something is true

execute unless entity @a[tag=vip] run say No VIP online

Java and Bedrock differences

  • Java has store, which saves a command result into a score or NBT. Bedrock does not.
  • Java has align, anchored, facing and rotated. Bedrock has a smaller set.
  • Dimension names differ in some versions. Use tab completion to confirm what your edition accepts.
  • Selector filters differ. Java uses distance and limit, Bedrock uses r and c. See target selectors explained.

Common mistakes

  • Forgetting run. Without it the command is incomplete.
  • Using as without at. The command then runs at the original position, not the target.
  • Using @e with no type. The command repeats for every entity in the world.
  • Writing the slash after run. Do not put a slash in front of the inner command.

FAQ

What does the execute command do in Minecraft?

It runs a command as a different entity, at a different position or dimension, or only when a condition is true.

What is the difference between execute as and execute at?

As changes who runs the command. At changes where it runs. Use both to act on a player at their location.

Does execute work on Bedrock?

Yes. Bedrock has used the Java-style syntax since 1.19.50, though it supports fewer subcommands.

How do I make a command run only if a block is under a player?

Use execute as @a at @s if block ~ ~-1 ~ gold_block run .

Why does execute say incomplete command?

You probably left out run, or the command after run is missing an argument.

Checked by the Game Respawned editorial team against the current Java and Bedrock versions. Spotted something out of date? Tell us.