NEWGTA 6 launches in 29 days — see the launch hub Game guides, cheat codes & secrets
Cheats · Minecraft

Minecraft Commands: 30 Most Useful Commands & Cheats (Copy-Paste)

The 30 Minecraft commands you’ll actually use, with copy-paste examples — from /gamemode and /give to /locate and keepInventory — for Java and Bedrock.

QUICK ANSWER

Minecraft commands are typed in chat starting with a slash. Turn on Allow Cheats first, press T (or /) to open chat, then type a command such as /gamemode creative, /give @s diamond 64 or /time set day and press Enter.

In this guide
  1. How to turn on cheats
  2. Target selectors
  3. The 30 most useful Minecraft commands
  4. What does ~ mean in commands?
  5. Item and mob IDs
  6. Handy command combos
  7. Useful /locate structure IDs
  8. Commands for server owners
  9. Common command errors and fixes
  10. Command blocks
  11. Commands for building faster
  12. Teleport tips
  13. Are commands cheating?
  14. Java vs Bedrock differences

Minecraft commands let you change almost anything about your world: switch game modes, give yourself items, teleport, change the weather or find the nearest village. Below are the 30 most useful Minecraft commands with ready-to-copy examples, plus how to turn cheats on and the target selectors that make commands powerful.

Open chat
T or / (Java) · chat button (Bedrock)
Needs
Cheats / operator permission
Affects achievements?
Bedrock: yes · Java: no achievements system
Target yourself
@s
All players
@a
Nearest player
@p

How to turn on cheats

  • 💻 Java Edition (single player): when creating a world, set Allow Cheats: ON. For an existing world, press Esc → Open to LAN → Allow Cheats: ON (this lasts until you quit).
  • 📱 Bedrock Edition: in world settings, turn on Activate Cheats. This disables achievements for that world permanently.
  • 🖥️ Servers: you need operator permission (/op yourname from the console).

Target selectors

SelectorMeans
@sYourself (the one running the command)
@pThe nearest player
@aAll players
@rA random player
@eAll entities (mobs, items, players)

The 30 most useful Minecraft commands

Game mode and difficulty

CommandWhat it does
/gamemode creativeSwitch to Creative mode (also survival, adventure, spectator)
/difficulty peacefulNo hostile mobs (also easy, normal, hard)
/gamerule keep_inventory trueKeep your items when you die (Bedrock: keepInventory)
/gamerule advance_time falseStop time (Bedrock: doDaylightCycle)
/gamerule advance_weather falseStop weather changing (Bedrock: doWeatherCycle)
/gamerule spawn_mobs falseStop mobs spawning naturally (Bedrock: doMobSpawning)

Items and XP

CommandWhat it does
/give @s diamond 64Give yourself 64 diamonds
/give @s netherite_swordGive any item by its ID
/xp add @s 30 levelsAdd 30 XP levels (Java; Bedrock: /xp 30L @s)
/enchant @s sharpness 5Enchant the item in your hand
/clear @sEmpty your inventory

Time and weather

CommandWhat it does
/time set dayMake it morning (also noon, night, midnight)
/weather clearStop rain (also rain, thunder)

Moving around

CommandWhat it does
/tp @s 100 64 -200Teleport to coordinates X Y Z
/tp @s PlayerNameTeleport to another player
/spawnpointSet your respawn point where you stand
/setworldspawnSet the world spawn point
/locate structure minecraft:village_plainsFind the nearest plains village
/locate biome minecraft:cherry_groveFind the nearest cherry grove

Effects and mobs

CommandWhat it does
/effect give @s night_vision 600 0Night Vision for 10 minutes
/effect give @s regeneration 60 2Regeneration III for 1 minute
/effect clear @sRemove all effects
/summon minecraft:horseSpawn any mob where you stand
/kill @e[type=minecraft:zombie]Remove all zombies
/effect give @s instant_health 1 4Instant full heal (there is no /heal command)

Building

CommandWhat it does
/fill ~ ~ ~ ~10 ~5 ~10 stoneFill an area with a block
/fill ~-5 ~ ~-5 ~5 ~5 ~5 airClear an area around you
/setblock ~ ~ ~ diamond_blockPlace one block
/cloneCopy a region to another place
/seedShow your world seed

What does ~ mean in commands?

The tilde ~ means “relative to me”. ~ ~ ~ is your exact position, ~ ~10 ~ is 10 blocks above you, and ~5 ~ ~ is 5 blocks east. It’s how you place things near yourself without knowing exact coordinates. Check your coordinates with F3 on Java or the Show Coordinates setting on Bedrock.

Item and mob IDs

Commands use IDs like diamond_sword or creeper — usually the name in lowercase with underscores. Our Minecraft items database lists every item, and the mobs database lists every mob. For example, the Diamond Sword page shows the recipe and stats, and its command ID is diamond_sword.

Handy command combos

  • 🛡️ Never lose items: /gamerule keep_inventory true (Java) or /gamerule keepInventory true (Bedrock)
  • ☀️ Endless sunny day: /time set day + /gamerule advance_time false + /weather clear
  • 💎 Find diamonds faster: /effect give @s night_vision 999999 0 + /tp @s ~ -58 ~ (careful — you may land in a cave)
  • 🏘️ Find a village: /locate structure #minecraft:village

Useful /locate structure IDs

StructureJava command
Stronghold (End portal)/locate structure minecraft:stronghold
Ancient city/locate structure minecraft:ancient_city
Trial chambers/locate structure minecraft:trial_chambers
Woodland mansion/locate structure minecraft:mansion
Ocean monument/locate structure minecraft:monument
Nether fortress/locate structure minecraft:fortress
Bastion remnant/locate structure minecraft:bastion_remnant
End city/locate structure minecraft:end_city

Commands for server owners

CommandWhat it does
/op PlayerNameGive a player operator permissions
/deop PlayerNameRemove operator permissions
/whitelist add PlayerNameAllow a player on a whitelisted server
/kick PlayerNameRemove a player from the server
/ban PlayerNameBan a player
/listShow who is online

Common command errors and fixes

  • ❗ “Unknown or incomplete command” — check the spelling, or that you’re on the right edition (Java and Bedrock differ).
  • ❗ “You do not have permission” — turn on cheats or ask a server operator.
  • ❗ “No entity was found” — your target selector didn’t match anyone, for example @e[type=zombie] with no zombies loaded nearby.
  • ❗ “That position is not loaded” — you tried to place blocks too far away. Move closer.

Command blocks

Command blocks run commands automatically, for example when powered by redstone. Get one with /give @s command_block (only in Creative with cheats on). They’re used to build adventure maps, mini-games and automatic farms.

Commands for building faster

Builders love commands. /fill can place up to tens of thousands of blocks at once, and adding hollow at the end makes a hollow box — perfect for quick room shells. /fill ~-10 ~-1 ~-10 ~10 ~-1 ~10 grass_block flattens a 21×21 floor under you. /clone copies a structure from one spot to another, and /setblock places a single block precisely, which is handy for redstone. Always save or back up your world before big edits, because commands can’t be undone with a button.

Teleport tips

Teleporting to a high Y value is safe, but teleporting low can drop you into stone, lava or caves. Use /tp @s ~ ~100 ~ to jump straight up for a view of the area, and /spawnpoint before risky trips. In the Nether, coordinates are 8 times smaller: dividing your Overworld X and Z by 8 tells you where to build a linked portal.

Are commands cheating?

It depends on how you play. In creative builds, adventure maps and servers, commands are simply tools. In a survival world, many players use only a few “quality of life” commands like /locate or keep inventory, while others avoid them completely for the challenge. There’s no wrong answer — just remember that on Bedrock, turning on cheats disables achievements for that world.

Tip: in Java Edition, press the Up arrow in chat to repeat the last command you typed — perfect for running the same /fill or /tp several times while building.

Java vs Bedrock differences

Most commands work the same way, but a few differ. Since Java 1.21.11, game rules use new lowercase names like keep_inventory and advance_time, while Bedrock keeps the old names like keepInventory. Bedrock uses /xp 30L @s for levels, while Java uses /xp add @s 30 levels. Some gamerules and structure names also differ, and Bedrock commands autocomplete differently. When in doubt, start typing and press Tab (Java) or watch the suggestions above the chat box.

Ready to play without commands too? Learn the best Y level for diamonds and the Minecraft potions brewing chart.

Sources

Frequently asked questions

How do you use commands in Minecraft?
Turn on cheats (Allow Cheats in Java, Activate Cheats in Bedrock), open chat with T or /, type the command and press Enter.
What is the command to keep inventory in Minecraft?
On Java Edition 1.21.11 and newer: /gamerule keep_inventory true. On Bedrock and older Java versions: /gamerule keepInventory true.
How do you give yourself items in Minecraft?
Use /give @s followed by the item ID and amount, for example /give @s diamond 64.
Do commands disable achievements in Minecraft?
In Bedrock Edition, turning on cheats disables achievements for that world. Java Edition uses advancements, which still work.

Written by

Faisal has been playing open-world games since the PS2 days of GTA San Andreas. He tests every cheat code and guide on Gamlora himself before it goes live, and keeps each page updated when games change.

Spotted something outdated? Tell us and we will fix it fast.