Skip to content
WikilyWIKILY
All games23 Wikis · pick your game
Commands and cheatsAll commands

Switch game

23 Wikis · pick your game
/data

Command

/data

Reads, changes, and removes the stored data (NBT) of block entities, entities, and command storage.

Syntax

/data get (block <target>|entity <target>|storage <target>) [<path> [<scale>]]
/data merge (block <target>|entity <target>|storage <target>) <nbt>
/data modify (block <target>|entity <target>|storage <target>) <targetPath> (append|merge|prepend|set) compute (block <computePos>|entity <computeTarget>) (float <provider>|integer <provider>)
/data modify (block <target>|entity <target>|storage <target>) <targetPath> (append|merge|prepend|set) compute default (float <provider>|integer <provider>)
/data modify (block <target>|entity <target>|storage <target>) <targetPath> (append|merge|prepend|set) from (block <source>|entity <source>|storage <source>) [<sourcePath>]
/data modify (block <target>|entity <target>|storage <target>) <targetPath> (append|merge|prepend|set) string (block <source>|entity <source>|storage <source>) [<sourcePath> [<start> [<end>]]]
/data modify (block <target>|entity <target>|storage <target>) <targetPath> (append|merge|prepend|set) value <value>
/data modify (block <target>|entity <target>|storage <target>) <targetPath> insert <index> compute (block <computePos>|entity <computeTarget>) (float <provider>|integer <provider>)
/data modify (block <target>|entity <target>|storage <target>) <targetPath> insert <index> compute default (float <provider>|integer <provider>)
/data modify (block <target>|entity <target>|storage <target>) <targetPath> insert <index> from (block <source>|entity <source>|storage <source>) [<sourcePath>]
/data modify (block <target>|entity <target>|storage <target>) <targetPath> insert <index> string (block <source>|entity <source>|storage <source>) [<sourcePath> [<start> [<end>]]]
/data modify (block <target>|entity <target>|storage <target>) <targetPath> insert <index> value <value>
/data remove (block <target>|entity <target>|storage <target>) <path>

Arguments

ArgumentKind of valueWhat to type
<target>Block positionWhat to read or change. After block it is a block position, after entity a single entity, after storage a namespaced id such as example:config.
<path>Data pathThe location of a value inside the data, for example Pos[1] or Items[0].id.
<scale>Decimal numberFor get: a number the value is multiplied by before it is rounded down and returned.
<nbt>Data in bracesFor merge: a compound written in braces, for example {NoAI:1b}.
<targetPath>Data pathFor modify: the location inside the target's data that is changed.
<computePos>Block positionFor a compute source with block: the block position the calculation looks at.
<provider>Decimal number providerFor a compute source: the number provider to calculate, as an id or written inline.
<computeTarget>Target selectorFor a compute source with entity: the entity the calculation looks at. One entity only.
<source>Block positionFor from and string: where the data is copied from. A block position, a single entity, or a storage id.
<sourcePath>Data pathThe location of the value to copy inside the source. Without it, all of the source's data is used.
<start>Whole numberFor string: the index of the first character to keep. Negative values count from the end.
<end>Whole numberFor string: the index where the text stops, not included. Negative values count from the end.
<value>Data valueFor a value source: the data to use, such as a number, text in quotes, a list, or a compound.
<index>Whole numberFor modify insert: the position in the list where the value is added. 0 is the start.

Details

Permission level2: operators, worlds with cheats on, command blocks and functions
Works inSingleplayer with cheats enabled and multiplayer servers. Needs permission level 2 (gamemasters): server operators, players with cheats, command blocks, and functions can all run it.
Resultget reports the data it found. The number /execute store saves is 1 for a whole target, the number rounded down for a number, the length for text, and the number of entries for a list or compound. With a scale, it is the number multiplied by the scale and rounded down. merge returns 1. remove returns how many values were removed. modify returns how many values were changed.
Targetsblock is a block that stores data, such as a Chest or a Sign, at a loaded position. entity is a single entity. storage is a named data store kept with the world that commands can use freely, and it is created the first time it is written to.
getShows all data of the target, or only the value at a path. With a scale, the value at the path must be a number. The path must point to exactly one value.
mergeCombines the given compound with the target's data, overwriting the keys that are named. Fails with "Nothing changed" if the data already has those values.
removeDeletes the value or values at the path. Fails if nothing was removed.
modify setReplaces the value at the target path with the source value.
modify append and prependAdd the source value to the end or the start of the list at the target path.
modify insertAdds the source value to the list at the target path at the given index.
modify mergeCombines the source compound into the compound at the target path. Both must be compounds.
Source: valueUses the data written directly in the command.
Source: fromCopies data from another block, entity, or storage, either everything or the value at a source path.
Source: stringCopies a value from a block, entity, or storage as text. The optional start and end cut out part of the text: start is the first character to keep, counted from 0, and end is where to stop. Negative numbers count from the end of the text. Only text and number values can be used.
Source: computeUses the result of a number provider, the same way /compute calculates it: default, block with a position, or entity with a target, followed by integer or float and the provider.
Players cannot be modifiedPlayer data can be read but not changed. Trying to change it fails with "Unable to modify player data".
Failure reasonsFails if the block does not store data ("The target block is not a block entity"), if the path does not exist, or if a modify command leaves the data unchanged.

Examples

/data get entity @s

Shows all of your own data.

/data get entity @s Pos[1]

Shows your height (y coordinate) and returns it rounded down.

/data get block ~ ~-1 ~ Items

Shows the items stored in the container below you.

/data merge entity @e[type=minecraft:zombie,limit=1,sort=nearest] {NoAI:1b}

Sets NoAI on the nearest Zombie so it stops moving on its own.

/data modify storage example:config counter set value 5

Stores the number 5 under counter in the storage example:config.

/data remove storage example:config counter

Deletes counter from the storage example:config.

Join the creator communityThe people who build the Minecraft Java Edition wiki are on our Discord. Ask questions or suggest pages.Join Discord (opens Discord in a new tab)