Skip to content

Type to search across every guide and reference page.

CommandsBoth · 26.x

How to Get a Command Block in Minecraft and Use It

Type /give @s command_block to get one; it isn't in the creative menu. The impulse, chain and repeat types, conditional mode, servers, starter builds.

By minecraft.bd Editorial Team·Updated

A command block runs a command when it gets a redstone signal, or constantly if you set it to. Get one with /give @s command_block (it isn’t in the creative menu), place it, open it in creative mode and type a command. They’re how adventure maps and minigames run without mods.

Getting and opening one

/give @s command_block
/give @s repeating_command_block
/give @s chain_command_block

You can also just give yourself a regular one and change its type in the menu. To edit it, you need to be in creative mode and have operator rights. Survival players can’t open them.

Java servers: set enable-command-block=true in server.properties, then restart. Our server setup guide shows where that file lives.

Bedrock: turn on “Command Blocks Enabled” in the world’s cheat settings.

The three types

Type Color Runs when
Impulse Orange Once each time it’s powered
Chain Green When the block pointing into it has just run
Repeat Purple Every game tick (20 times a second) while powered

Each block has an arrow on its sides showing which way it points. A chain block only runs if the block behind it points into it.

Settings in the menu

  • Needs Redstone / Always Active. Always Active runs without a redstone signal. Most repeat and chain blocks are set to Always Active.
  • Conditional / Unconditional. A conditional block runs only if the block behind it succeeded. Use it for “if this, then that” logic.
  • Track output (Java). Shows the last result. Turn it off on blocks that run constantly.
  • Delay in ticks (Bedrock). Waits before running. Useful for timed sequences without redstone clocks.

Three starter builds

1. A welcome button. Impulse block, Needs Redstone, with a button on it:

/tellraw @p {"text":"Welcome to the map!","color":"gold"}

2. Permanent night vision for everyone. A repeat block, Always Active:

/effect give @a night_vision 20 0 true

(Bedrock: /effect @a night_vision 20 0 true.) Twenty seconds refreshed every tick means the effect never flickers.

3. A checkpoint. A repeat block that detects a player standing on a gold block, then a conditional chain block that sets their spawn:

/execute as @a at @s if block ~ ~-1 ~ gold_block

then, in the chain block (Conditional, Always Active):

/execute as @a at @s if block ~ ~-1 ~ gold_block run spawnpoint @s ~ ~ ~

The /execute command page explains how those conditions work.

Common mistakes

  • Nothing happens. The block is set to Needs Redstone with no power. Add a button or set it to Always Active.
  • Chain block doesn’t fire. It’s facing the wrong way, or it’s set to Needs Redstone.
  • Chat spam. Turn off command block output with the gamerule (command_block_output on Java 1.21.11+, commandBlockOutput before and on Bedrock).
  • Lag. Dozens of repeat blocks running heavy commands every tick will slow a world down.
  • Including the slash or not. Both work in a command block; the slash is optional.

For more items like command blocks, see /give. Once you’re comfortable, look at popular adventure maps to see what other creators built with them, or go back to the commands hub.

Common questions

How do you get a command block?

Run /give @s command_block with cheats on. Command blocks aren't in the creative inventory and can't be crafted.

Why won't my command block work on a server?

On Java servers, set enable-command-block=true in server.properties and restart. You also need operator status and creative mode to edit one.

How do I stop command blocks spamming chat?

Turn off command block output. Java 1.21.11 and later: /gamerule command_block_output false. Older Java and Bedrock: /gamerule commandBlockOutput false.

Sources & verification

Facts on this page are checked against these references and in-game behavior for the stated edition(s). how we verify.

Keep reading