Skip to main content

Player Commands

Commands that directly affect players, their inventory, experience, and status effects.

/clear
Game Master

Removes items from a player's inventory. Can target specific items and limit how many are removed.

v1.4.2
/effect
Game Master

Gives or removes status effects from entities. Effects include potion effects like speed, strength, invisibility, etc.

v1.5
/enchant
Game Master

Enchants the item held in a player's main hand. Only allows enchantments that are compatible with the held item and does not exceed the enchantment's maximum level.

v1.4.4
/experience
Game Master

Adds, sets, or queries experience points or levels for one or more players. Identical to /xp.

v1.13
/gamemode
Game Master

Sets a player's game mode to survival, creative, adventure, or spectator.

Beta 1.8
/give
Game Master

Gives one or more items to one or more players. The item can include NBT data via component syntax.

Alpha v1.0.15
/kill
Game Master

Kills entities (players, mobs, or other entities). If no target is specified, kills the executing entity.

Alpha v1.2.6
/spawnpoint
Game Master

Sets the spawn point for one or more players. When a player dies, they respawn at their spawn point.

v1.4.2
/spectate
Game Master

Causes a player in spectator mode to spectate (follow the viewpoint of) another entity. Running without arguments stops spectating.

v1.15
/teleport
Game Master

Teleports entities to a location, another entity, or adjusts their rotation. Full form of /tp with extended facing options.

Classic 0.0.18a
/tp
Game Master

Teleports entities to a specified location, to another entity, or with a specific rotation. Alias for /teleport.

Classic 0.0.19a_06
/trigger
All Players

Modifies a scoreboard objective of type 'trigger'. This command can be used by non-operator players, making it useful for custom maps and voting systems.

v1.8
/xp
Game Master

Adds, sets, or queries experience points or levels for one or more players. This is an alias for /experience.

v1.0

Who a player command can target

Every command here except /trigger takes a target. That can be a player name or a selector, and the selector decides who gets hit when the command runs:

@p
The nearest player. Typed in chat that is you; in a command block it is whoever stands closest to the block.
@a
Every player on the server.
@r
One random player. Java never picks a mob here, so for a random entity use @e[sort=random,limit=1].
@s
The entity running the command. Inside /execute as, that is each selected entity in turn.
@e
All entities: mobs, dropped items, armor stands and players alike. Narrow it down with arguments such as type=zombie or distance=..10.
@n
The nearest entity of any kind. Added in Java 1.21.

Not every command takes every target. /give, /clear, /experience, /gamemode and /spawnpoint only accept players, so a plain @e is refused before anything happens. /effect, /enchant, /kill and /teleport work on any entity, which is how a zombie ends up with Speed II.

Giving and clearing items

/give puts items straight into the inventory. What doesn't fit drops at the player's feet, and in Java only that player can pick it up. Extra data has gone in square brackets after the item ID since Java 1.20.5, so /give @s wooden_sword[enchantments={sharpness:3,knockback:2}] hands you a wooden sword with Sharpness III and Knockback II. Java 1.21.5 dropped the levels wrapper from that component, so a guide that still shows enchantments={levels:{...}} was written for an older version.

One /give is capped at 100 stacks' worth of the item: 6,400 diamonds, 1,600 ender pearls or 100 swords. Ask for more and you get an error message and nothing else.

/clear on its own empties your inventory, the off hand and the small crafting grid included. The item can be a tag, so /clear @a #minecraft:wool takes all 16 colors of wool from everyone at once. With a maxCount of 0 nothing is removed at all. The command only counts the matching items, which is how a command block checks whether a player is carrying something.

Status effects and enchantments

/effect give takes the effect, then a duration in seconds from 1 to 1,000,000 or the word infinite (added in Java 1.19.4), then an amplifier from 0 to 255 and finally hideParticles. Leave the duration out and the effect lasts 30 seconds; Instant Health, Instant Damage and Saturation read the number as ticks instead. The amplifier counts from 0, so /effect give @p speed 60 1 is Speed II for a minute.

A second effect of the same kind only takes over when it lasts longer or is stronger. If it is stronger but shorter, the old one is kept underneath and comes back when the strong one runs out. Setting hideParticles to true also hides the effect icon in Java. /effect clear without a target clears your own effects, and with an effect ID it removes only that one. Java 26.2 has 40 effects to choose from.

/enchant changes the item in the main hand of a player, or of a mob holding a weapon, tool or piece of armor, and it follows the same rules as an anvil. The level can't go above the maximum, the enchantment has to suit the item, it can't clash with one that is already there (Piercing and Multishot on one crossbow, say), and Java refuses an item that already has that enchantment at any level. For Sharpness X, or Sharpness and Smite on one sword, use /give with the enchantments component, which skips those checks.

Experience: points or levels

/experience and its short name /xp have three actions. add also takes negative numbers to take experience away, set replaces the value, and query reports it for one player. Without levels or points at the end, add and set work in points; query always needs one of the two words.

The two units behave differently. Added points count toward the score on the death screen and can carry someone over several levels at once. Levels only change the number, and the bar keeps the share of progress it had. Setting points only moves the bar inside the current level, so a number bigger than that bar can hold makes the command fail.

Game mode, spawn point and spectating

/gamemode wants the full name in Java: survival, creative, adventure or spectator. Java 1.13 removed the numbers and the short letters, which only Bedrock still accepts. Without a target it changes your own mode. The mode new players start in is set with /defaultgamemode, one of the gameplay commands.

/spawnpoint sets where a player respawns, optionally with a position and a direction. In Java 26.2 the direction is a yaw followed by a pitch (the pitch arrived in 1.21.9), so /spawnpoint @p ~ ~ ~ 90 0 makes the nearest player respawn right here, facing west and looking straight ahead. A yaw of 0 faces south, 90 west, 180 north and -90 east. The spawn lands in the dimension the command runs in, so from the Overworld /execute in minecraft:the_nether run spawnpoint @s 0 70 0 puts yours in the Nether.

/spectate only works for a player who is already in spectator mode. /spectate Alex puts your camera on Alex, a second name picks which spectator does the watching, and /spectate on its own lets go again. Since Java 1.19.4 the target can be in another dimension.

Teleporting

/teleport and /tp are the same command. With one argument you move yourself; with two, the first is who moves and the second is where, so /tp @a @s pulls every player to you. Coordinates can be absolute, relative with ~ or local with ^, where ^ ^ ^5 means five blocks in the direction you are looking.

Teleporting to an entity copies that entity's rotation. Moving someone to coordinates keeps the way they were facing, unless you add a yaw and pitch, or use facing with a position or facing entity with a target, which aims at the feet unless you add eyes. Java runs no safety check at the destination, so a teleport into stone suffocates, and chunks that don't exist yet are generated just before the move.

Coordinates always stay in the dimension the command runs in. /execute in minecraft:the_nether run tp @s 0 100 0 is how you jump to the Nether, while /tp @s Alex follows Alex into whatever dimension they are in.

Killing

/kill with no target kills whoever runs it. Since Java 1.20 it deals generic_kill damage, which armor, Protection and Resistance don't reduce, and a Totem of Undying won't save anyone. Java kills players in Creative too. Mobs still drop their loot, and slimes, magma cubes and sulfur cubes above the smallest size still split. An ender dragon skips its death animation and opens the exit portal straight away.

Entities that aren't mobs simply vanish. /kill @e[type=!player] therefore also clears item frames, armor stands, paintings, boats, minecarts and dropped items along with the mobs, so name the type you actually want gone.

/trigger works without op

/trigger is the one player command with permission level 0. It only changes a scoreboard objective with the trigger criterion that has been enabled for that player, and every use switches it off again until /scoreboard players enable runs once more. /trigger vote adds 1, and add or set with a number do the rest. Setting up the objective is explained with the data commands.

The other twelve player commands need permission level 2: cheats on in single player, op on a server.