/data
Gets, merges, modifies, or removes NBT data from entities, block entities, or storage. A powerful command for advanced data manipulation.
Overview
Gets, merges, modifies, or removes NBT data from entities, block entities, or storage. A powerful command for advanced data manipulation. In vanilla Minecraft Java Edition it is one of the data commands and has been available since version 1.13.
It is invoked as /data and accepts 2 required arguments (
The 'storage' target type provides persistent key-value storage in the world data. Player entities have restrictions on which NBT fields can be written. Block entity data can be read and modified for things like signs, chests, and command blocks.
Targets are entity
Syntax & Arguments
/data <get|merge|modify|remove> <target> <path> [<value>]The full syntax is /data . Angle brackets < > mark required arguments and square brackets [ ] mark optional ones; a vertical bar | between words means you pick exactly one of those literals. You must always supply
- action
- Required, of type a literal. get, merge, modify, or remove.
- target
- Required, of type a data_target. The target: entity <selector>, block <pos>, or storage <id>.
- path
- Optional, of type a nbt_path. The NBT path to operate on.
- value
- Optional, of type a nbt. The NBT value to set or merge.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| action | literal | Required | get, merge, modify, or remove. |
| target | data_target | Required | The target: entity <selector>, block <pos>, or storage <id>. |
| path | nbt_path | Optional | The NBT path to operate on. |
| value | nbt | Optional | The NBT value to set or merge. |
Examples
The 3 examples below are ready to copy and adapt. For instance, /data get entity @s Inventory displays your full inventory as NBT data. Each example varies the arguments to show a different real use of /data; read the note under every snippet to see exactly what changes.
/data get entity @s InventoryDisplays your full inventory as NBT data.
/data merge entity @e[type=villager,limit=1,sort=nearest] {Invulnerable:1b}Makes the nearest villager invulnerable.
/data modify storage my_namespace:my_data scores append value 100Appends the value 100 to the 'scores' list in a custom data storage.
Permission Level & Requirements
/data sits at permission Level 2 - Game Master / Cheats, which means it needs permission level 2, the level cheats grant to single-player worlds and that operators hold by default.
In a single-player world you must have "Allow Cheats" turned on (or open the world to LAN with cheats) before it will run; on a multiplayer server the player needs to be an operator at the matching level.
This reference describes the Java Edition 1.21 form of the command; Bedrock Edition may use slightly different argument formats.
Common Mistakes
- Trying to modify player data directly, many player NBT fields are read-only via /data.
- Incorrect NBT path syntax, paths use dot notation for objects and square brackets for lists.
Notes
The 'storage' target type provides persistent key-value storage in the world data. Player entities have restrictions on which NBT fields can be written. Block entity data can be read and modified for things like signs, chests, and command blocks.
Related Commands
If /data is part of your toolkit, the commands below are the ones you will most often reach for alongside it: /scoreboard, /summon, and /setblock. They cover closely related tasks, so the links above jump straight to each one.
Frequently Asked Questions about /data
What does the /data command do in Minecraft?
Gets, merges, modifies, or removes NBT data from entities, block entities, or storage. A powerful command for advanced data manipulation. It belongs to the data command group and was added in Java Edition 1.13.
What is the correct syntax for /data?
/data
What permission level does /data need?
It requires permission Level 2 - Game Master / Cheats. On a server the player must be an operator at that level, or have cheats enabled in single-player.
What is a common mistake when using /data?
Trying to modify player data directly, many player NBT fields are read-only via /data.
Can you give an example of /data in use?
Yes. /data merge entity @e[type=villager,limit=1,sort=nearest] {Invulnerable:1b} — makes the nearest villager invulnerable.
Need a Minecraft server?
Try these commands on Astroworld or host your own server.
Try Astroworld Hosting