Command syntax helper

Syntax and examples for common commands.

Command Syntax Helper

Target Selectors

@aAll players
@eAll entities
@pNearest player
@rRandom player
@sExecuting entity (self)

Selector Arguments

x, y, zOrigin coordinates for distance/range checks
rMaximum radius from origin
rmMinimum radius from origin
dx, dy, dzVolume size (box selection)
mGame mode (0=survival, 1=creative, 2=adventure, 3=spectator)
lMaximum XP level
lmMinimum XP level
cMax count, negative = farthest first
teamTeam name (! prefix = not in team)
namePlayer or entity name (! prefix = exclude)
rx, rxmMax / min vertical rotation (pitch)
ry, rymMax / min horizontal rotation (yaw)
typeEntity type (minecraft:zombie, ! prefix = exclude)
tagScoreboard tag (! prefix = exclude)
nbtMatch NBT data
scoresScoreboard scores: {obj=min..max}
advancementsFilter by advancement completion
predicateFilter by loot table predicate

Common Commands

/give <player> <item> [count]

Give an item to a player.

/give @p minecraft:diamond 64

/clear [player] [item] [maxCount]

Remove items from a player's inventory.

/clear @a minecraft:dirt

/tp <player> <x> <y> <z>

Teleport a player to coordinates.

/tp @p 100 64 -200

/tp <player> <destination>

Teleport a player to another player.

/tp Steve Alex

/kill [player]

Kill a player or entity.

/kill @e[type=zombie]

/xp <amount> [player]

Give XP points or levels (use L suffix for levels).

/xp 10L @p

/gamemode <mode> [player]

Set a player's game mode.

/gamemode creative @p

/effect give <player> <effect> [seconds] [amplifier]

Apply a potion effect to a player.

/effect give @p minecraft:speed 60 1

/effect clear [player] [effect]

Remove potion effects from a player.

/effect clear @a

/enchant <player> <enchantment> [level]

Enchant the item held by a player.

/enchant @p sharpness 5

/setblock <x> <y> <z> <block> [mode]

Place a block at the given coordinates.

/setblock ~ ~1 ~ minecraft:stone

/fill <x1> <y1> <z1> <x2> <y2> <z2> <block>

Fill a region with blocks.

/fill ~-5 ~-1 ~-5 ~5 ~-1 ~5 minecraft:grass_block

/clone <x1> <y1> <z1> <x2> <y2> <z2> <dx> <dy> <dz>

Copy a region of blocks to another location.

/clone 0 64 0 10 74 10 100 64 100

/summon <entity> [x] [y] [z] [nbt]

Summon an entity at a location.

/summon minecraft:zombie ~ ~ ~ {CustomName:"\"Boss\""}

/time set <value>

Set the time of day (0=dawn, 6000=noon, 12000=dusk, 18000=midnight).

/time set day

/weather <clear|rain|thunder> [duration]

Set the weather.

/weather clear 1000

/difficulty <easy|normal|hard|peaceful>

Set server difficulty.

/difficulty hard

/gamerule <rule> [value]

Get or set a game rule.

/gamerule keepInventory true

/setworldspawn [x] [y] [z]

Set the world spawn point.

/setworldspawn 0 64 0

/spawnpoint [player] [x] [y] [z]

Set a player's spawn point.

/spawnpoint @p ~ ~ ~

/data get entity <target> [path]

Read NBT data from an entity.

/data get entity @p Health

/data merge entity <target> <nbt>

Merge NBT data into an entity.

/data merge entity @p {Health:20.0f}

/data modify entity <target> <path> set value <value>

Set a specific NBT field on an entity.

/data modify entity @e[type=zombie,limit=1] CustomName set value '"Boss"'

/scoreboard objectives add <name> <criteria>

Create a scoreboard objective.

/scoreboard objectives add kills playerKillCount

/scoreboard players set <player> <objective> <score>

Set a player's score.

/scoreboard players set @p kills 0

/scoreboard players add <player> <objective> <amount>

Add to a player's score.

/scoreboard players add @p kills 1

/tag <player> add <tag>

Add a tag to an entity.

/tag @p add vip

/op <player>

Grant operator status to a player.

/op Steve

/deop <player>

Revoke operator status from a player.

/deop Steve

/ban <player> [reason]

Ban a player from the server.

/ban Steve Griefing

/whitelist add <player>

Add a player to the whitelist.

/whitelist add Steve