Minecraft Command Guide

Intro

Minecraft has a versatile command system that can be used to enchance your Minecraft worlds in a way you never thought possible. The basic structure of a command is /commandname argument1 argument2 argument3 …

You may be familiar with commands such as /gamemode and /gamerule. To run a command, press the / key to open the chat/command interface (or press T to open the chat interface and then type a slash), type in the command, and press Enter.

Most commands can be run from the chat interface, however command blocks are much more versatile, as they can be triggered by redstone, repeatedly run commands, and run commands based on the success of another command. To give yourself a command block, run the following command:

      /give @s minecraft:command_block
    

Data Types

Commands use the SNBT (stringified Named Binary Tag) format for data (a user-friendly version of the NBT format that Minecraft uses internally).

The types of data are listed below. If you know a statically-typed programming language, some of these will be familiar to you.

Type Description Format* Example(s) from Minecraft*
byte Signed byte value. Range is -128 ≤ n ≤ 127. Often used as a boolean value, with 0b corresponding to false and 1b corresponding to true. <value>b {Glowing: 1b}
{Slot: 13b}
short int Signed short int value (number). Range is -32768 ≤ n ≤ 32767. <value>s {lvl: 21s}
{Air: 300s}
int Signed int value (number). Range is -2147483648 ≤ n ≤ 2147483647. <value> {color: 65280}
long int Signed long int value (number). Range is -9223372036854775808 ≤ n ≤ 9223372036854775807. <value>L {UUIDMost: -210473289432L}
float Signed float value (number, including decimal values). <value>f {Rotation: [22.5f, -11.25f]}
double Signed double value (number, including decimal values). <value>d OR <value with decimal point> {damage: 2.0d}
{Motion: [0.0d, 2.0d, 0.0d]}
{Pos: [1238.0, 70.0, -549.0]}
byte array List of bytes. [B;<value>, <value>, …] (none)
string 65535-byte UTF-8 string. Commonly used characters are usually 1 byte. "<value>" {Name: "My Cool Sword"}
list List of tags. [<value>, <value>, …] {Enchantments: [{id: "sharpness", lvl: 32767s}]}
compound List of named tags (order doesn't matter). Similar structure to that of a JSON object. {<tag name>: <value>, <tag name>: <value>, …} {id: "sharpness", lvl: 32767s}
int array List of int values. [I;<value>, <value>, …] (none)
long int array List of long int values. [L;<value>, <value>, …] (none)

* Note that spaces after colons and commas are usually omitted when entering commands, but have been added here for better legiblity.