Table of contents

The commands in this article use Minecraft Java Edition syntax, including namespaced item and structure names. For Bedrock Edition, compare against Microsoft Learn’s Popular Commands. Java Edition renamed its game rules to lowercase names with underscores in 1.21.11, and the old names now fail with “Incorrect argument for command”. Java 1.21.10 and earlier and Bedrock Edition still use the old names, so this article lists both names for every game rule. The full mapping is in Minecraft gamerule old and new names. Before you run a command, turn cheats on or have operator permissions on the server, as described in Command permissions. You can check the parameters your current version supports with /help <command name> and Tab completion.
Common commands
| Command | What it does |
|---|---|
| /gamerule keep_inventory true | Keep inventory on death: you keep your inventory and experience |
| /gamerule mob_griefing false | Mob griefing off: mobs can’t change the terrain |
| /gamerule fire_spread_radius_around_player 0 | Fire spread off: fire stops spreading |
| /time set day | Set the time to day |
| /weather clear | Clear the weather |
| /effect give @p minecraft:night_vision 60 | Give yourself night vision for 60 seconds |
| /give @p minecraft:diamond 64 | Give the nearest player 64 diamonds |
| /locate structure #minecraft:village | Find the nearest village |
| /kill | Kill yourself |
| /clear | Clear the inventory of the specified player |
The table above uses the syntax from Java 1.21.11 and later. If another version gives an error, use the syntax in the table below instead. Java Edition shows its version number in the bottom-left corner of the main menu.
| What it does | Java 1.21.11 and later | Java 1.21.10 and earlier | Bedrock Edition |
|---|---|---|---|
| Keep inventory on death | /gamerule keep_inventory true |
/gamerule keepInventory true |
/gamerule keepInventory true |
| Mob griefing off | /gamerule mob_griefing false |
/gamerule mobGriefing false |
/gamerule mobGriefing false |
| Fire spread off | /gamerule fire_spread_radius_around_player 0 |
/gamerule doFireTick false |
/gamerule doFireTick false |
| Night vision for 60 seconds | /effect give @p minecraft:night_vision 60 |
/effect give @p minecraft:night_vision 60 |
/effect @p night_vision 60 |
| Find a village | /locate structure #minecraft:village |
/locate structure #minecraft:village |
/locate structure village |
| Add 999 levels | /xp add @p 999 levels |
/xp add @p 999 levels |
/xp 999L @p |
Finding a village used different syntax before Java 1.19. Java 1.18.2 uses /locate #village, and Java 1.18.1 uses /locate village.
After you send a command, the chat should show the result. Commands that change the time, the weather or your inventory should also show the matching change in the game. If you see “Unknown or incomplete command. See below for error” or “Incorrect argument for command”, check the edition, the version and the spelling first.
Some commands can use a target selector to choose who they affect:
| Selector | Meaning |
|---|---|
| @p | The nearest player |
| @r | A random player |
| @a | All players |
| @e | All entities, including mobs, items and projectiles |
| @s | The player or entity that runs the command |
Switch between Creative and Survival with /gamemode
Use /gamemode followed by the mode you want. In a singleplayer world, turn on “Allow Commands” when you create the world. For a world that already exists, open “World Options…” from the Game Menu. If the menu doesn’t have that option, use “Open to LAN” instead. On a server, you need operator permissions. The steps and screenshots are in Command permissions.
| Command | What it does |
|---|---|
| /gamemode creative | Switch to Creative |
| /gamemode survival | Switch to Survival |
| /gamemode spectator | Switch to Spectator |
| /gamemode adventure | Switch to Adventure |
Bedrock Edition also accepts the full names, as well as abbreviations and numbers. For example, /gamemode c or /gamemode 1 switches to Creative, and /gamemode s or /gamemode 0 switches to Survival. Spectator mode only works with spectator. Java Edition accepts only the full names since 1.13.
Difficulty, time and weather
Change the game difficulty:
| Command | Difficulty |
|---|---|
| /difficulty peaceful | Peaceful |
| /difficulty easy | Easy |
| /difficulty normal | Normal |
| /difficulty hard | Hard |
Change the time and the weather:
| Command | Result |
|---|---|
| /time set day | Day |
| /time set noon | Noon |
| /time set night | Night |
| /time set midnight | Midnight |
| /weather clear | Clear |
| /weather rain | Rain |
| /weather thunder | Thunder |
Game rules
The tables below list the new and old commands side by side. For old names in existing worlds, command blocks and data packs, see Minecraft gamerule old and new names.
Keep inventory, mob griefing and fire spread
| Java 1.21.11 and later | Java 1.21.10 and earlier, and Bedrock Edition | What it does |
|---|---|---|
| /gamerule keep_inventory true | /gamerule keepInventory true | Keep your inventory and experience when you die |
| /gamerule keep_inventory false | /gamerule keepInventory false | Restore the default death drops |
| /gamerule mob_griefing false | /gamerule mobGriefing false | Mobs can’t change the environment |
| /gamerule mob_griefing true | /gamerule mobGriefing true | Restore the default mob interaction with the environment |
| /gamerule fire_spread_radius_around_player 0 | /gamerule doFireTick false | Fire stops spreading |
| /gamerule fire_spread_radius_around_player 128 | /gamerule doFireTick true | Restore fire spread and natural burnout |
Time, weather and sleeping
| Java 1.21.11 and later | Java 1.21.10 and earlier, and Bedrock Edition | What it does |
|---|---|---|
| /gamerule advance_time false | /gamerule doDaylightCycle false | Stop the day-night cycle |
| /gamerule advance_time true | /gamerule doDaylightCycle true | Restore the day-night cycle |
| /gamerule advance_weather false | /gamerule doWeatherCycle false | Stop the weather cycle |
| /gamerule advance_weather true | /gamerule doWeatherCycle true | Restore the weather cycle |
| /gamerule players_sleeping_percentage 0 | /gamerule playersSleepingPercentage 0 | One sleeping player skips the night |
| /gamerule players_sleeping_percentage 101 | /gamerule playersSleepingPercentage 101 | Sleeping can’t skip the night |
| /gamerule spawn_phantoms false | /gamerule doInsomnia false | Phantoms don’t spawn |
| /gamerule spawn_phantoms true | /gamerule doInsomnia true | Restore phantom spawning |
When you idle with a Carpet Mod fake player, an awake fake player counts as an online player, so other players can’t skip the night by sleeping. The fix is in Carpet Mod fake player commands.
Respawn radius, fall damage, raids, PvP and recipes
| Java 1.21.11 and later | Java 1.21.10 and earlier, and Bedrock Edition | What it does |
|---|---|---|
| /gamerule respawn_radius 1 | /gamerule spawnRadius 1 | Shrink the world spawn area to a very small radius |
| /gamerule respawn_radius 50 | /gamerule spawnRadius 50 | Enlarge the world spawn area |
| /gamerule fall_damage false | /gamerule fallDamage false | Turn off fall damage |
| /gamerule fall_damage true | /gamerule fallDamage true | Restore fall damage |
| /gamerule raids false | /gamerule disableRaids true | Disable village raids. The old and new values are opposite. Bedrock Edition has no such rule |
| /gamerule raids true | /gamerule disableRaids false | Restore village raids. The old and new values are opposite. Bedrock Edition has no such rule |
| /gamerule pvp false | /gamerule pvp false | Turn off player-versus-player damage. The game rule exists from Java 1.21.9 |
| /gamerule pvp true | /gamerule pvp true | Restore player-versus-player damage |
| None | /gamerule recipesUnlock true | On Bedrock Edition, players still unlock recipes step by step by obtaining items |
| None | /gamerule recipesUnlock false | On Bedrock Edition, recipes show up right away without unlocking them first |
Items and effects
Give a player an item:
| Command | What it does |
|---|---|
| /give @p minecraft:wooden_axe | Give the nearest player a wooden axe |
| /give @p minecraft:iron_ingot 64 | Give the nearest player 64 iron ingots |
| /give @p minecraft:diamond 64 | Give the nearest player 64 diamonds |
| /give @p minecraft:netherite_ingot | Give the nearest player a netherite ingot |
Give a player an effect:
| Command | What it does |
|---|---|
| /effect clear @p | Clear all effects from yourself |
| /effect clear @p night_vision | Clear only night vision from yourself |
| /effect give @p minecraft:regeneration 60 | Give the nearest player Regeneration for 60 seconds |
| /effect give @p minecraft:regeneration infinite 255 true | Long-lasting Regeneration with particles hidden |
| /effect give @p minecraft:night_vision 60 | Give the nearest player night vision for 60 seconds |
| /effect give @p minecraft:night_vision infinite 255 true | Long-lasting night vision with particles hidden |
Night vision command
For night vision, use /effect give @p minecraft:night_vision 60. It gives the nearest player 60 seconds of night vision, and the screen brightens right away when you mine, explore caves or dive. The three parameters after the effect are the duration in seconds, the amplifier and whether to hide particles. Change the duration to infinite and the effect never ends on its own. The amplifier doesn’t change how bright night vision is, and true hides the particles on your character. Java 1.19.3 and earlier don’t have infinite and answer with “Expected integer”, so write the duration as 1000000 there.
To remove only night vision, use /effect clear @p night_vision. /effect clear @p also clears every other effect.
On Bedrock Edition, /effect doesn’t take give. Write /effect @p night_vision 60, and clear an effect with /effect @p clear. Permanent night vision on Bedrock Edition is /effect @s night_vision infinite 255 true, and on success the chat shows “Gave Night Vision * 255 to infinite from 1.21.40. Older versions also need the duration written as 1000000.
Experience and finding a village
Set a player’s experience:
| Command | What it does |
|---|---|
| /xp add @p 999 levels | Add 999 levels to the nearest player |
| /xp add @p 999 points | Add 999 experience points to the nearest player |
| /xp query @p levels | Show the nearest player’s levels |
| /xp query @p points | Show the nearest player’s experience points |
| /xp set @p 999 levels | Set the nearest player’s levels directly |
| /xp set @p 1 points | Set the nearest player’s experience points directly |
On Bedrock Edition, /xp can only add experience. Levels are /xp 999L @p and points are /xp 999 @p, and there is no add, set or query.
/locate prints the coordinates of the nearest structure in chat, and you can then use /tp to teleport there. The coordinates can land inside terrain, and a Survival player stuck in a block suffocates.
| Command | What it does |
|---|---|
| /locate structure minecraft:ancient_city | Find an Ancient City |
| /locate structure minecraft:mansion | Find a Woodland Mansion |
| /locate structure #minecraft:village | Find a village |
Java Edition villages come in five structures: plains, desert, savanna, snowy and taiga. Use #minecraft:village to search all of them at once, or name one of them, such as minecraft:village_plains. Bedrock Edition uses /locate structure village. The names for strongholds, Ancient Cities, biomes and Nether structures, for both Java Edition and Bedrock Edition, are in the locate command guide for strongholds, ancient cities and biomes.
Server management commands
When you type a command in the server window, leave out the /. Players need it when they type in the game. These are the commands you use most after you set up a server:
| Command | What it does | Details |
|---|---|---|
op PlayerName |
Make a player an operator | Command permissions |
whitelist add PlayerName |
Add a player to the whitelist | Java Edition server setup |
save-off, save-all flush, save-on |
Pause autosave before a world backup and resume it afterward | Server world backup |
reload, datapack list |
Load data packs and check the list | Install data packs on a server |
Summary
Whether a command worked shows in the chat reply and in the game state. When you get a syntax error, first work out whether you are on Java Edition or Bedrock Edition, then fix the command with /help and Tab completion for your current version.