How to open the command console and enter commands in Minecraft PC
To use commands in Minecraft PC (Java Edition), press the forward slash key (/) to open the chat window. A text cursor will appear at the bottom of your screen. Type your command after the slash and press Enter to execute it. The command will run when ready if the syntax is correct.
Commands only work in worlds where cheats are enabled. When you create a new world, you can toggle "Allow Cheats" to ON before entering the world. If you are already in a world without cheats enabled, you cannot turn them on without creating a new world or using a backup.
In Minecraft Bedrock Edition (the version on Windows 10/11 through the Microsoft Store), the process is similar: press / to open the chat, type your command, and press Enter. However, some commands differ between Java and Bedrock, so check which version you own before following a command guide.
Key Takeaways
- Press the forward slash (/) to open the command console, then type your command and press Enter to run it.
- Cheats must be enabled in your world settings before any commands will work.
- Common commands include /give to add items, /teleport to move to coordinates, /time to change day or night, and /weather to control rain and storms.
- Commands use specific syntax with parameters in square brackets or angle brackets; if a command does not work, check spelling and parameter order.
- Java Edition and Bedrock Edition have different command sets, so a command that works in one version may not work in the other.
Teleportation and movement commands
The /teleport command (or /tp for short) moves you or another player to a specific location. The basic syntax is /teleport @s x y z, where x, y, and z are the coordinates you want to reach. @s means "yourself"; you can replace it with a player name to teleport someone else. For example, /teleport @s 100 64 200 moves you to coordinates 100, 64, 200.
You can also teleport to another player using /teleport @s [player name]. This is useful in multiplayer worlds when you want to join a friend quickly. The y coordinate (the middle number) is your height; 64 is sea level in most Minecraft worlds, so use higher numbers to teleport to mountain peaks and lower numbers for caves.
Item and inventory commands
The /give command adds items directly to your inventory or another player's inventory. The syntax is /give @s [item name] to give yourself an item, or /give [player name] [item name] to give it to someone else. For example, /give @s diamond 64 gives you 64 diamonds.
Item names in Minecraft use underscores instead of spaces. A diamond sword is diamond_sword, not "diamond sword". If you are unsure of an item's exact name, you can look it up in the Minecraft wiki or experiment by typing the command and reading the error message, which often suggests the correct name.
The /clear command removes items from your inventory. /clear @s empties your entire inventory, while /clear @s diamond removes only diamonds. This is useful if you accidentally gave yourself the wrong item.
Time and weather commands
The /time set command controls the time of day. /time set day sets it to morning (6:00 AM), /time set night sets it to evening (18:00 PM), and /time set noon sets it to midday. You can also use numbers: /time set 0 is dawn, /time set 6000 is noon, and /time set 12000 is dusk.
The /weather command controls rain and storms. /weather clear stops rain and clears the sky, /weather rain starts rain, and /weather thunder starts a thunderstorm. You can add a duration in seconds: /weather clear 3600 clears the weather for one hour.
Gamemode and difficulty commands
The /gamemode command changes how you play. /gamemode survival puts you in Survival mode (you take damage, need food, and can die), /gamemode creative gives you infinite blocks and the ability to fly, and /gamemode adventure is a restricted mode where you cannot break or place blocks. /gamemode spectator lets you fly around and see through walls without interacting with the world.
The /difficulty command sets how hard the game is. Options are peaceful (no hostile mobs spawn), straightforward (mobs deal less damage), normal (standard difficulty), and hard (mobs deal more damage and can break down doors). For example, /difficulty peaceful removes all hostile mobs from your world.
Block placement and world editing commands
The /setblock command places a single block at a specific location. The syntax is /setblock x y z [block name]. For example, /setblock 100 64 200 diamond_block places a diamond block at those coordinates. This is useful for building structures quickly or fixing mistakes.
The /fill command fills a rectangular area with blocks. The syntax is /fill x1 y1 z1 x2 y2 z2 [block name], where the two sets of coordinates define opposite corners of the rectangle. For example, /fill 0 0 0 10 10 10 stone fills a 10×10×10 cube with stone. This command can lag your game if the area is too large, so start small.
Player effect and attribute commands
The /effect command gives you or another player a status effect. /effect give @s speed 300 2 gives you the Speed effect for 300 seconds (5 minutes) at level 2 (faster movement). Other common effects include strength (more damage), resistance (less damage taken), invisibility (become invisible to mobs), and night_vision (see in the dark).
The /kill command removes you or another player from the world. /kill @s kills yourself (you respawn at your spawn point), and /kill [player name] kills another player. This is useful if you are stuck or want to reset your position.
Frequently Asked Questions
Why does my command say "Unknown command" even though I typed it correctly?
Cheats may not be enabled in your world. Create a new world and toggle "Allow Cheats" to ON before entering. If cheats are on, check that you included the forward slash (/) at the start and that you spelled the command and all parameters correctly. Java and Bedrock editions use different commands, so verify you are using the right version's syntax.
Can I use commands in multiplayer worlds?
Yes, but only if you are the world owner or have operator status. In a multiplayer world, the owner can type /op [player name] to give another player permission to use commands. Once you have operator status, you can use any command in that world.
What does the @ symbol mean in commands?
The @ symbol is a target selector that refers to players or entities. @s means "yourself", @a means "all players", @p means "the nearest player", and @r means "a random player". You can use these in any command that targets a player, such as /teleport @a or /give @p diamond.
How do I find the coordinates of a location I want to teleport to?
Press F3 (or Fn + F3 on Mac) to open the debug screen. Your current coordinates appear in the top left corner under "XYZ". Walk to the location you want, note the coordinates, then use /teleport to jump back there later. You can also use /tp @s to see your current position in the chat.
Can I undo a command if I made a mistake?
There is no built-in undo command. If you accidentally filled a large area with the wrong block or deleted items, you will need to fix it manually or load a backup of your world. Always save your world before experimenting with large commands like /fill.