Commands

Commands are advanced functions activated by typing certain strings of text.

In a regular Minecraft client or the stand alone client, commands are entered via Minecraft's chat window, which is displayed by pressing the key (default) or  key. Using the key will also enter the forward slash that commands require as a prefix, so it is a useful shortcut. Pressing while entering commands cycles through possible commands or arguments.

Commands may also be entered in a multiplayer server's console, but are not preceded by a when entered this way. Commands in Command Blocks can be preceded by a slash, but it is not required.

The majority of commands are only available in the following situations:


 * In a Minecraft multiplayer server game, entered by an operator or Command Block.
 * In other multiplayer games, entered by the player who opened a LAN game with cheats enabled, or is hosting their own multiplayer server
 * In singleplayer, if cheats were enabled at world creation (via the "More World Options..." button).

Some commands are also available in singleplayer even when cheats are not enabled (see player commands below).

Note: In singleplayer worlds where cheats were not enabled at creation, they can be enabled on a temporary basis by opening the current game session to LAN play ( -> "Open to LAN", then "Allow Cheats" button and "Start LAN World"). You do not actually need to be on a LAN or have others join. This is not permanent, but will allow the use of commands until you quit the world, and changes you make via commands (items spawned, etc.) will be saved with the world. You can do this each time you start playing the world again. Note that this will disable game pausing, so from then on you should get somewhere safe before using the and Options screens.

Legend
In the listings below, command text is formatted as follows:

Target selector
Instead of player names, it is possible to trigger multiple different targets at the same time, using the following variables:

Target selector arguments
After using a target (, ,  , or  ) you can optionally use arguments. This is how you use the arguments: NOTE: Make sure you do NOT add any spaces or full stops in between the brackets.

Example: Breakdown:

@p only specifies the nearest player.

x=1,y=30,z=26 sets the middle of the radius to x: 1, y: 30 and z: 26.

r=10 sets the (max) search radius to 10.

rm=2 sets the minimum search radius to 2.

m=1 only specifies players with gamemode 1 (creative).

c=3 specifies the three first players in the list (note: for @p, the default c is 1, unlike @e and @a).

l=25 specifies all players with xp-level 25 or less.

lm specifies all players with xp-level 3 or more.

score_Kills_min=1 specifies all players with at least 1 "Kills" (score).

score_Kills=2 specifies all players with at most 2 "Kills" (score).

team=Red specifies all players in "Red" (team).

Alternatively, the coordinates and maximum (but not minimum!) radius can be provided more concisely as long as they're the first (up to four) arguments without keys, for instance:

is identical to the previous example.

Because the argument 'c' uses players from the end of a list first when negative,  may be used to select the farthest player instead of the nearest one (for @e[c=-1] this will select the farthest entity).

finds the farthest in the search radius (100).

If  is specified along with ,   and/or  , only entities within the overlap of both search regions will be found.

Player commands
These commands can be used in the chat window by any player who is allowed to connect to a server, and can also be used in singleplayer whether or not cheats are enabled.

| x and z must fall within the range -30,000,000 to 30,000,000 (exclusive), and y must be at least 0. If coordinates aren't specified the entity will spawn at the player's location (or inside a command block if the command was executed by one). |- | tellraw   | Sends a JSON message to specified player(s), allowing formatting and clickable actions in chat text. Color defaults to white and all formatting (bold, italic, etc.) defaults to false. | playername must be online, and the message text must be correctly coded in JSON. |- | testfor  [dataTag] | Used to test whether the given player | entity (or selector) could be located, and whether it has all tags specified by dataTag. A redstone comparator as output from a command block with this command will indicate the number of players/entities matched by it. For example, "testfor @a[r=3]" will output the number of players within 3 meters of the command block, and "testfor @e[type=Arrow,r=3] {inGround:1b}" will output the number of arrows stuck in a block within 3 meters. | selector and dataTag must be valid and match some entity if specified. |- | testforblock     [datavalue] [dataTag] | Used to test whether a particular block is in the x, y and z coordinates specified. Datatags will not work unless a special syntax is used to specify what type of NBT tag is used (s for Short, b for Byte, l for Long, f for Float and d for Double). Also all relevant tags must be included even if they are unused (e.g.: Chest contents must include Slot, id, Damage, and Count.) | tilename must exist, datavalue must exist if specified, and dataTag must evaluate if specified. |- | testforblocks          [mode] | Compare the blocks at two locations in cuboid regions. mode is "masked" or "all". | |- | time set <(number | day | night)>||Sets the world time. number is an integer between 0 and 24000, inclusive, where 0 is dawn, 6000 midday, 12000 dusk and 18000 midnight. Number can be greater than 24000; in this case, the time of day wraps around, but the moon's phase is advanced. However, Setting the time "backward" (earlier than the current time) does not change the moon. "time set day" sets the time to 1000, and "time set night" sets the time to 13000. | Number must be 0 or positive, or "day" or "night". |- | time add <number> | Increments the world time, as above. | Number must be 0 or positive. The daytime wraps, and the moon's phase advances; adding 24000 will advance the moon's phase by one day. |- | toggledownfall | Toggles rain and snow. |Always succeeds. |- | tp [player | entity] <targetplayer | targetentity> | Teleports player | entity to targetplayer | targetentity 's location. If no player/entity is specified, it will teleport yourself. | player | entity is not optional in command blocks. Both players must be online. |- | tp [player | entity] <x> <y> <z> [<y-rot> <x-rot>] | Teleports player player | entity (or yourself if no player/entity is specified) to coordinates x,y,z. (the y value cannot be smaller than 0). Can also relatively move the player/entity by adding the ~ character before the coordinate value. For example typing /tp John ~3 64 ~3 will teleport a player called John 3 blocks away from his current x and z, and to y 64. Additionally, y-rot and x-rot may optionally be used to specify the yaw and pitch in degrees - these also accept ~. | x and z must fall within the range -30,000,000 to 30,000,000 (exclusive), and y must be at least 0. player | entity is not optional in command blocks, and the player must be online. |- | weather <(clear | rain | thunder)> [seconds] | Changes the weather for the specified duration. | Seconds must be at least 1, and cannot be greater than 1,000,000, and a valid weather condition must be provided. |- | worldborder center <x> <z> | Sets the center point for the world's border to be centered on. | x and z must fall within the range -30,000,000 to 30,000,000 (exclusive). |- |  worldborder set <diameter> [time] | Sets the world's border into place. Diameter is based on the world's border center. Time is the time it should take for the border to move from its previous location to the newly given location in seconds. If "time" is not specified, it happens immediately. Default diameter is 60 million (+30,000,000 to -30,000,000), though once changed this value is no longer allowed. | diameter must fall within the range 1 to 30,000,000 (inclusive). |- | xp <amount> [playername] | Gives the specified user the given number of orbs. Maximum is 2,147,483,647 per command. Negative amounts may not be used to remove experience points. || Amount can be at most 2,147,483,647. Playername is not optional in command blocks, and player must be online. |- | xp <amount>L [playername] | Gives playername the amount number of experience levels. Maximum is 2,147,483,647 — if a player is given levels pushing them past this limit, they get reset to 0. Negative amounts may be used to remove experience levels. | Amount must be between -2,147,483,648 and 2,147,483,647, inclusive. Playername is not optional in command blocks, and player must be online. |}

Multiplayer-only commands
These commands are only available in multiplayer mode, and are usable by ops (operators) from the server console as well as through the chat window when prefixed by the command character.

With the exception of the list command, none of these commands can be executed by a command block, and none make use of target selectors.

Many of these commands can be used on players who have never been to the server, or even on names which are not (or cannot be) registered as Minecraft accounts.

Data tags
NBT tags can be specified for items and entities created with the, and other commands. Data tags are data structures. The format is JSON, although it is not strict (lenient). The data is represented as a comma separated list of pairs. Each pair has the format. The key is the name of the NBT tag and the value is the data that should be assigned to it. Tag names are case-sensitive, and whitespace outside keys or values is ignored.

The value can be different types:


 * String is a piece of text, can be wrapped with double-quotes. Double quotes have to be used if the String contains commas, curly braces or square brackets. To use double-quotes inside Strings, the quote is escaped by a backslash . When using the summon command, escaping is disabled (except for double quotes) and keys must not be quoted (probably a bug ). This causes an issue where trailing backslashes do not work (as do any other things that need to be escaped), even when escaped properly. The reason is that it escapes the quotation mark after the string which causes a malformed JSON object.
 * Number are 1 or more digits that can have a leading sign ( / ). They're classified in Integers, that don't have a decimal mark, Doubles, that uses a dot as a decimal mark, and Floats, that also have   appended after the number. Examples:  ;  ; &
 * List (or 'Array') is multiple, comma separated values wrapped with square brackets. The containing values do not need to be of the same type.
 * Boolean can either be  or , but using Numbers works, too. When using numbers, everything between 0 and below 1 is false, other is true.
 * Compound or 'Object' is a container for data structures (as explained above). They are wrapped with curly braces.
 * Notice: The Data tag itself is a Compound. Example: 


 * null This is a placeholder an empty value. Do not put quotes.

When commands such as /testfor, /testforblock, and /clear are used to match NBT tags, they only check for the presence of the given tags in the target entity/block/item. This means that the entity/block/item may have additional tags and will still match. This is true even for lists/arrays: the order of a list is not acknowledged, and as long as every requested element is in the list, it will match even if there are additional elements.

For a complete listing of defined tags (though not all can be modified by commands), see:
 * Blocks
 * Entities
 * Mobs
 * Projectiles (arrows, fireballs, thrown potions, etc.)
 * Items (items on the ground)
 * Vehicles (boats, minecarts, etc.)
 * Dynamic Tiles (primed TNT, falling sand/gravel)
 * Other Entities (firework rockets, paintings, and item frames)
 * Tile Entities (chests, furnaces, command blocks, mob spawners, signs, etc.)
 * Player
 * Items (items in player's inventory or containers)

For a complete list of identifiers, see:
 * blocks
 * items
 * entities
 * enchantments
 * status/potion effects
 * attributes

Raw JSON Text
The command uses a specific lenient JSON format for raw chat messages. Similar to the NBT format notation above, concepts such as Strings, Objects (Compounds), and Lists are used to represent the various properties of raw chat.

For a direct tutorial to tellraw commands, see this thread. For a tool to easily create tellraw commands, see this. Note that both links are external to the Minecraft Wiki and may be outdated.

The format of "<raw JSON message>" is a JSON Object which supports the following (mostly optional) elements:
 * The base chat component Object
 * : A string representing raw text to display directly in chat. Note that selectors such as "@a" and "@p" are not translated into player names.
 * : A list of additional objects, sharing the same format as the base object.
 * A list element with the same format as the base object (recursive). Note that all properties of this object are inherited by children except for text, extra, translate, with, and score. This means that children will retain the same formatting and events as this object unless they explicitly override them.
 * : The color to render this text in. Valid values are "black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", "white", and "reset" (cancels out the effects of colors used by parent objects). Technically, "bold", "underline", "italic", "strikethrough", and "obfuscated" are also accepted, but it may be better practice to use the tags below for such formats.
 * : Boolean (true/false) - whether to render text in bold. Defaults to false.
 * : Boolean (true/false) - whether to render text underlined. Defaults to false.
 * : Boolean (true/false) - whether to render text in italics. Defaults to false.
 * : Boolean (true/false) - whether to render text with a strikethrough. Defaults to false.
 * : Boolean (true/false) - whether to render text obfuscated. Defaults to false.
 * : When the text is shift-clicked by a player, this string will be inserted in their chat input. It will not overwrite any existing text the player was writing.
 * : Allows for events to occur when the player clicks on text.
 * : The action to perform when clicked. Valid values are "open_url" (opens value as a URL in the player's default web browser), "run_command" (has value entered in chat as though the player typed it themselves. This can be used to run commands, but the command will fail if the player does not have the required permissions to use it), and "suggest_command" (similar to "run_command", but the text only appears in the player's chat input, and is not automatically entered. Unlike insertion, this will replace the existing contents of the chat input).
 * : The URL, chat, or command used by the specified action. Note that commands must be prefixed with the usual "/" slash.
 * : Allows for a tooltip to be displayed when the player hovers their mouse over text.
 * : The type of tooltip to show. Valid values are "show_text" (shows raw JSON text), "show_item" (shows the tooltip of an item which can have NBT tags), "show_achievement" (shows formatted text describing an achievement or statistic. Normal achievement names are green, final achievement names are dark_purple, and statistic names are gray. In addition, a description is given for achievements), and "show_entity" (shows an entity's name, possibly its type, and its UUID).
 * : The formatting of this tag varies depending on the action. Note that "show_text" is the only action to support an Object as the value; all other action values are Strings and should thus be wrapped in quotes.
 * "show_text": Can be either a raw String of text, or an Object with the same formatting as this base object. Note that clickEvent and hoverEvent do not function within the tooltip, but the formatting and extra tags still work.
 * "show_item": A string formatted like item NBT data. Contains the "id" tag, and optionally the "Damage" tag and "tag" tag (which is the same compound used as "dataTag" in the command).
 * "show_achievement": The achievement or statistic's name. This uses the same format as achievement and statistic Scoreboard objective criteria and the command.
 * "show_entity": A string formatted like a compound with the string values "type" (such as "Zombie"), "name", and "id" (should be an entity UUID, but can actually be any string).
 * : The translation identifier of text to be displayed using the player's selected language. This identifier is the same as the identifiers found in lang files from assets or resource packs. The translated text will only be displayed if the text string is not used.
 * : A list of chat component arguments and/or string arguments to be used by translate.
 * The arguments are text corresponding to the arguments used by the translation string in the current language, in order (for example, the first list element corresponds to "%1$s" in a translation string).
 * : A compound for displaying a player's score in an objective. Displays "?" if the player is not tracked in the given objective. Ignored completely if text or translate is present.
 * : The name of the player whose score should be displayed. Selectors (such as @p) cannot be used, but "fake" player names created by the scoreboard system can be used. In addition, if the name is "*", it will show the player's own score (for example,  will show every online player their own score in the "obj" objective).
 * : The internal name of the objective to display the player's score in.

Due to the extra tag, the above format may be recursively nested to produce very complicated and functional text strings. However, a raw json string doesn't have to be complicated at all: virtually all properties are optional and may be left out.

To be valid, each object must have at least either text, translate, or score (everything else is optional). As a matter of shorthand, however, the entire Object may be substituted for a String. In this case, that string will be considered the value of the text property. For example,  is equivalent to. This shorthand substitution is valid anywhere a raw text object is required (including the base <raw json message> argument of, the elements of the extra list, and the value of a "show_text" hover_event).

Finally, unlike other commands using JSON, Strings support Unicode via the notation , where #### is the Unicode hexadecimal number for the desired character.