Minecraft command basics

If you're new to commands, start here. This page covers everything from enabling cheats to target selectors and coordinates — the basics shared by nearly every command

1. Turn on cheats first

Most commands won't work at all unless cheats are enabled for that world

  • Java Edition — new world: When creating the world, click "More World Options" and set Allow Cheats: ON
  • Java Edition — an existing world: Press Esc, choose "Open to LAN", set Allow Cheats: ON then click "Start LAN World" (this only lasts until you leave the world — you'll need to repeat it next time)
  • Bedrock Edition: Go to Settings → Game → turn on Activate Cheats

On Bedrock, enabling cheats permanently disables achievements for that world. If you still want to earn achievements, test commands in a separate world instead

2. Where to type commands

  • Chat box — press T to open chat (or press / to open chat with the / already typed) then type the command
  • Command Block — a block that runs commands automatically, used for maps or in-game systems. You need the /give command to obtain one first, since it isn't in the creative inventory
  • Function files — for datapacks/behavior packs that run multiple command lines at once

Chat commands must always start with /, but a command block accepts them with or without it. Commands generated by our tools already include the /

3. Target selectors

Instead of typing a player name directly, we use shorthand starting with @ for more flexible targeting. These 5 selectors work on both Java and Bedrock

SelectorMeaningExample use
@pNearest playerGive an item to whoever stands nearest the command block
@aAll playersBroadcast a message to the whole server
@sSelf (whoever runs the command)Change your own game mode
@rOne random playerRandomly give out a prize
@eEvery entity (including mobs, not just players)Remove all mobs

You can add extra conditions in square brackets, e.g. @e[type=zombie] means "every zombie" or @a[distance=..10] means "every player within 10 blocks"

The shorthand @p @a @s @r @e is the same on both editions, but theconditions inside the square brackets are written differentlybetween Java and Bedrock (the examples above use Java syntax). If it fails on Bedrock, double-check the condition syntax

4. Coordinates

In-game coordinates are 3 values in order: X Y Z where Y is height. There are 3 ways to write them

FormMeaningExample
Plain numbers Absolute coordinates — a fixed position in the world regardless of where the command runs from 100 64 -200
~ (tilde) Relative coordinates — measured from where the command runs ~ ~1 ~ = same spot but 1 block higher
^ (caret) Coordinates relative to the direction you're facing, in order left/up/forward ^ ^ ^3 = 3 blocks in front of us

Using ~ ~ ~ alone means "exactly where the command runs" — this is the default our tools fill in

5. How Java and Bedrock differ

These two editions usedifferent command syntax A command copied from a video or site made for Java usually won't work on Bedrock, and vice versa

  • Java Edition — the separately-purchased computer version (Windows/Mac/Linux). It supports more complex commands, such as naming an item, adding lore, and adding enchantments all in one command
  • Bedrock Edition — the mobile, console, and Windows (Microsoft Store) version. Some command syntax differs and it supports fewer options

Our tools always ask you to pick an edition and version first, then automatically adjust the syntax and hide options that edition doesn't support — so you don't have to worry about mixing syntax from the wrong edition

6. Common problems

SymptomCommon cause
Says you don't have permission to use the command Cheats aren't enabled yet (see step 1), or you're not an operator on the server
The command turns red while typing The item/mob id is misspelled, or you're using syntax from the wrong edition
Copied from YouTube but it doesn't work The video may be for a different edition or version — command syntax can change between versions
Runs but nothing happens The target selector doesn't match anyone — e.g. using @e[type=zombie] when no zombie is nearby

Ready? Try generating a command

Pick the tool you need, fill in the form, and copy the command straight into your game

Other guides to read next

  • Target selectors in depth — A deep look at the square-bracket arguments, from type and distance through limit and sort, plus how to work out why a command matched nobody
  • Coordinates: numbers, ~, and ^ — Why ~ and ^ cannot be mixed, why blocks end up in the wrong place, and which form to reach for in which situation
  • Command blocks — Take the commands you generated and run them automatically — once, on repeat, or chained one after another
  • Why an old give command stops working — Legacy NBT, 1.20.5 components, and 1.21.5 components side by side — compared using commands built by the generator itself
  • Scoreboard basics — Create an objective the game tracks for you — or track it yourself from a command block — then use the score as a condition elsewhere
  • The execute command — The most powerful command in the game, taken apart piece by piece — how as differs from at, and why reordering changes the result
  • My command does not work — Work back from the error the game shows you, with the usual cause behind each one