Menu
Skip to article

Minecraft commands: a list of guides with examples

All command guides on the site in one list: what each command does, which guide covers it, and ready-to-type examples for Java Edition.

3314 min
Guide

Commands are short text instructions typed in the chat that change the game directly: they give items, change the time and weather, teleport players and switch game modes. They only work in a world with cheats allowed or on a server where you have operator rights; if your world was created without cheats, see how to enable cheats in an existing world.

Most commands exist in both Java and Bedrock Edition, but the syntax is not always the same. The examples on this page use Java syntax; the guides point out Bedrock differences where they matter.

How to enter a command

  • Press T to open the chat, type the command and press Enter. Pressing / instead opens the chat with the slash already typed.

  • In Java Edition, press Tab while typing: the game completes command names, selectors and item or block IDs and shows the arguments it expects.

  • The chat accepts up to 256 characters. Longer commands, such as items with many components, go into a command block, which also runs a command on a redstone signal.

Getting started

  • Enabling cheats: turn on cheats in a Java world created without them, for one session via Open to LAN or permanently by editing level.dat.

  • Command block: get a command block with /give, place it and set it up, plus other ways to obtain one.

Items and player

  • /give: get any item with the current item component syntax (Java 1.20.5+) for enchantments, names, lore and unbreakable gear, god items, legacy NBT for older versions and Bedrock.

  • /effect: apply any effect with a chosen duration and level, remove effects with /effect clear, and the full list of effect IDs.

  • /xp: add levels or experience points, for example 1000 levels at once, remove them with negative values, and the Java and Bedrock syntax.

  • /gamemode: switch to Creative and other modes, use F3 + F4 in Java, change another player's mode, and why /gamemode c works in Bedrock but not in Java.

  • keepInventory: the game rule that keeps your items and experience after death: how to turn it on and off and what to do when the command fails.

World and time

  • /time: skip the night with /time set day, stop the day-night cycle, set exact values from 0 to 24000 and check the current time.

  • /weather: stop rain with /weather clear, keep it off for good, start a thunderstorm, and the difference between Java seconds and Bedrock ticks.

  • /gamerule: the /gamerule syntax, true/false and number values, and a table of the main rules with their default values.

  • /locate: find the nearest biome, structure or point of interest, the syntax before and after 1.19, and how to teleport to the result.

  • /fill: fill an area with blocks between two corners, use relative ~ coordinates and the replace, keep, outline, hollow and destroy modes, plus fixes for common errors.

  • /spawnpoint: set your own or another player's respawn point, use coordinates and selectors, and how it differs from /setworldspawn.

Teleport and entities

  • /tp: teleport to a player or to exact and relative coordinates, change the view direction, and move between dimensions with /execute.

  • /kill: remove mobs, dropped items and armor stands to reduce lag, limit the command by radius, and exclude players from it.

Quick reference: commands and examples

Command

What it does

Example

/give

gives you 64 diamonds

/give @s diamond 64

/effect

night vision with no time limit

/effect give @s night_vision infinite

/xp

adds 30 levels

/xp add @s 30 levels

/gamemode

switches you to Creative mode

/gamemode creative

/time

sets the time to morning

/time set day

/weather

stops rain and thunder

/weather clear

/gamerule

keeps items and experience after death

/gamerule keep_inventory true

/locate

shows the coordinates of the nearest plains village

/locate structure village_plains

/locate

shows the nearest cherry grove biome

/locate biome cherry_grove

/fill

builds a hollow 11 x 4 x 11 stone room around you

/fill ~-5 ~ ~-5 ~5 ~3 ~5 stone hollow

/spawnpoint

sets your respawn point where you stand

/spawnpoint @s ~ ~ ~

/tp

teleports you to x 100, y 64, z -200

/tp @s 100 64 -200

/kill

removes all dropped items

/kill @e[type=item]

Since Java Edition 1.21.11, game rules use snake_case names: keep_inventory instead of keepInventory, advance_time instead of doDaylightCycle. In older Java versions and in Bedrock, use the old names, for example /gamerule keepInventory true.