
Command
/data
Reads, changes, and removes the stored data (NBT) of block entities, entities, and command storage.
| /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> |
| Argument | Kind of value | What to type |
|---|---|---|
| <target> | Block position | What 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 path | The location of a value inside the data, for example Pos[1] or Items[0].id. |
| <scale> | Decimal number | For get: a number the value is multiplied by before it is rounded down and returned. |
| <nbt> | Data in braces | For merge: a compound written in braces, for example {NoAI:1b}. |
| <targetPath> | Data path | For modify: the location inside the target's data that is changed. |
| <computePos> | Block position | For a compute source with block: the block position the calculation looks at. |
| <provider> | Decimal number provider | For a compute source: the number provider to calculate, as an id or written inline. |
| <computeTarget> | Target selector | For a compute source with entity: the entity the calculation looks at. One entity only. |
| <source> | Block position | For from and string: where the data is copied from. A block position, a single entity, or a storage id. |
| <sourcePath> | Data path | The location of the value to copy inside the source. Without it, all of the source's data is used. |
| <start> | Whole number | For string: the index of the first character to keep. Negative values count from the end. |
| <end> | Whole number | For string: the index where the text stops, not included. Negative values count from the end. |
| <value> | Data value | For a value source: the data to use, such as a number, text in quotes, a list, or a compound. |
| <index> | Whole number | For modify insert: the position in the list where the value is added. 0 is the start. |
| Permission level | 2: operators, worlds with cheats on, command blocks and functions |
| Works in | Singleplayer with cheats enabled and multiplayer servers. Needs permission level 2 (gamemasters): server operators, players with cheats, command blocks, and functions can all run it. |
| Result | get 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. |
| Targets | block 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. |
| get | Shows 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. |
| merge | Combines 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. |
| remove | Deletes the value or values at the path. Fails if nothing was removed. |
| modify set | Replaces the value at the target path with the source value. |
| modify append and prepend | Add the source value to the end or the start of the list at the target path. |
| modify insert | Adds the source value to the list at the target path at the given index. |
| modify merge | Combines the source compound into the compound at the target path. Both must be compounds. |
| Source: value | Uses the data written directly in the command. |
| Source: from | Copies data from another block, entity, or storage, either everything or the value at a source path. |
| Source: string | Copies 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: compute | Uses 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 modified | Player data can be read but not changed. Trying to change it fails with "Unable to modify player data". |
| Failure reasons | Fails 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. |
/data get entity @sShows 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 ~ ItemsShows 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 5Stores the number 5 under counter in the storage example:config.
/data remove storage example:config counterDeletes counter from the storage example:config.



