Commands turn Minecraft into a sandbox you control: teleport across the map, find any structure, give yourself items, freeze time for building. This is the short list of commands most players actually use, with syntax that works in Java Edition 26.3. Copy them as they are and change the parts in angle brackets.
Before you start: turn cheats on
- Single player: create the world with Allow Cheats on, or open the pause menu, choose Open to LAN, switch Allow Cheats on and start the LAN world. That last trick works on any world, but only until you quit.
- Servers: you need operator permission. See our guide to ops, whitelists and permissions.
- Press T or / to open chat. Tab completes command names, items and players, which saves a lot of typing.
Target selectors and coordinates
| Selector |
Means |
@s |
yourself |
@p |
the nearest player |
@a |
all players |
@r |
a random player |
@e |
all entities |
@n |
the nearest entity |
Filter them in square brackets: @e[type=minecraft:zombie,distance=..20] is every zombie within 20 blocks.
Coordinates can be absolute (100 64 -200), relative to you with ~ (~ ~10 ~ is ten blocks above you), or local to where you are looking with ^ (^ ^ ^5 is five blocks in front of your face).
The essentials
| Command |
What it does |
/gamemode creative |
Switch game mode: survival, creative, adventure or spectator |
/difficulty hard |
peaceful, easy, normal or hard |
/time set day |
Also night, noon, midnight, or a number of ticks |
/weather clear |
Also rain or thunder, optionally with a duration |
/tp @s 100 80 -200 |
Teleport yourself to coordinates |
/tp @s Steve |
Teleport to another player |
/seed |
Show the world seed |
/kill @e[type=minecraft:item] |
Remove every dropped item (great for lag) |
Items and enchantments
| Command |
What it does |
/give @s minecraft:diamond 64 |
Give an item; the number is the amount |
/give @s minecraft:elytra |
The minecraft: prefix is optional |
/clear @s minecraft:dirt |
Remove an item from your inventory; leave the item off to clear everything |
/enchant @s minecraft:sharpness 5 |
Enchant the held item, up to the enchantment's normal maximum |
/xp add @s 30 levels |
Add experience levels (leave off levels to add points) |
Finding things
| Command |
What it does |
/locate structure minecraft:village_plains |
Nearest structure and its coordinates |
/locate biome minecraft:cherry_grove |
Nearest biome |
/locate poi minecraft:nether_portal |
Nearest point of interest, like a portal or job block |
The result is clickable: click the coordinates in chat to fill in a teleport command. Structure names include minecraft:ancient_city, minecraft:trial_chambers, minecraft:stronghold, minecraft:mansion and minecraft:monument. The tab key lists every option. For a stronghold the old-fashioned way, there is our stronghold guide.
Effects
| Command |
What it does |
/effect give @s minecraft:night_vision infinite 0 true |
Night vision forever, without particles |
/effect give @s minecraft:speed 60 2 |
Speed III for 60 seconds (levels count from 0) |
/effect clear @s |
Remove every effect |
infinite gives an effect with no time limit, and the final true hides the particles. Remember the level number starts at 0: 0 is level I, 1 is level II.
Building
| Command |
What it does |
/fill ~-5 ~ ~-5 ~5 ~5 ~5 minecraft:glass hollow |
Fill a box; hollow keeps only the walls |
/fill ... minecraft:air replace minecraft:water |
Replace one block type with another in a box |
/clone <from> <to> <destination> |
Copy a region somewhere else |
/setblock ~ ~-1 ~ minecraft:diamond_block |
Place one block |
/fill has modes: replace, hollow, outline, keep and destroy (which drops items like mining). A single fill can change up to 32,768 blocks by default.
Spawn points and mobs
| Command |
What it does |
/spawnpoint |
Set your respawn point where you stand |
/setworldspawn |
Set the world spawn where you stand |
/summon minecraft:zombie ~ ~ ~ |
Spawn a mob at your position |
/ride @s mount @n[type=minecraft:horse] |
Mount the nearest horse |
/attribute @s minecraft:scale base set 2 |
Make yourself twice as big (set it back with 1) |
Server and technical
| Command |
What it does |
/gamerule keep_inventory true |
Change a game rule; names changed in 1.21.11, see the gamerules list |
/tick query |
Show how fast the server is running |
/tick freeze and /tick unfreeze |
Pause and resume the game world |
/tick rate 40 |
Run the game at a different speed (20 is normal) |
If you run a server, /tick query is a quick health check. For a proper look at what is slowing things down, our guide to MSPT and the spark profiler goes further.
Common mistakes
- "Unknown or incomplete command": a typo, or cheats are off. Use Tab completion to catch typos.
- Old syntax from old videos:
/effect @p speed and numeric item IDs are from before 1.13. Use /effect give and item names like minecraft:diamond.
- Old gamerule names:
keepInventory became keep_inventory in 1.21.11.
- Effect levels off by one:
/effect give @s minecraft:haste 60 1 is Haste II, not Haste I.
Frequently asked questions
How do you turn on cheats in an existing Minecraft world?
Open the pause menu, choose Open to LAN, turn on Allow Cheats and start the LAN world. Cheats stay on until you leave the world; you can repeat it any time.
How do you find a village with a command?
Use /locate structure minecraft:village_plains, or another village type such as village_desert or village_taiga. Click the coordinates in the reply to teleport there.
How do you give yourself infinite night vision?
Type /effect give @s minecraft:night_vision infinite 0 true. The word infinite removes the time limit and the last value hides the particles.
What does @s mean in Minecraft commands?
It is a target selector meaning the player or entity running the command, usually yourself. @p is the nearest player, @a all players and @e every entity.
Why does my old command not work in the new version?
Command syntax changed in 1.13, and gamerule names changed in 1.21.11. Use item names instead of numbers, /effect give instead of /effect, and snake_case gamerule names.
Comments
Loading...