The /data command in Minecraft: read and change the NBT of mobs, blocks and players
/data is how you look inside and change what's in the world: a player's health, what a chest holds, whether a zombie has AI or what a villager is called. It's the command behind maps, minigames and servers that build things without plugins, and also the handiest way to find out why something isn't working. Here are its four parts in the form today's Java version uses.
How it's written
It has four forms: get to read, merge to add or change tags, modify to touch a single one and remove to take it away. After that comes what it acts on: entity and a selector, block and some coordinates, or storage and a name.
You need to be an operator (level 2) or have cheats on in a single-player world. On a server, you op yourself from the console with op YourName (the guide to giving op).
With entity, the selector has to pick exactly one: @e[type=minecraft:zombie] on its own won't do, but @e[type=minecraft:zombie,limit=1,sort=nearest] (the nearest zombie) will. The options in square brackets are in the selectors guide.
With block, the block has to store its own data: chests, barrels, furnaces, signs, spawners… With stone or dirt, the game answers «The target block is not a block entity».
Rather not set it up yourself? Minecraft servers from €6 a month, no contract and a full refund within 72 hours. Or create a free Minecraft server, no card needed.
Reading data: /data get
Everything it has
/data get entity @sshows all your data in chat. It's long, but everything is there; with a mob, check first with F3 that the selector points at the one you want.One specific value
/data get entity Ana Healthtells you Ana's health;XpLevel, her level;foodLevel, her hunger, andDimension, the world she's in.Where someone is
/data get entity Ana Posgives her three coordinates, and/data get entity Ana Pos[1]just the height: the number in square brackets picks an element from a list, starting at 0.What a chest holds
/data get block 100 64 -200 Itemslists what's inside the chest at those coordinates, slot by slot. Look at the block and press F3 to see its coordinates.A player's inventory
/data get entity Ana Inventoryfor what she's carrying and/data get entity Ana EnderItemsfor her ender chest. Since 1.21.5, worn armour and the off hand are separate, inequipment.
Changing a mob or a block: /data merge
merge mixes what you write with what it already has: it adds the new tags, changes the ones that match and leaves the rest as it was. If everything already had those values, it answers «Nothing changed. The specified properties already have these values».
Tags go in curly braces and yes/no values as 1b (yes) and 0b (no). A misspelled name gives no error: the game stores it and ignores it, so if something doesn't change, check the capital letters.
A mob that stays still, with no AI
/data merge entity @e[type=minecraft:villager,limit=1,sort=nearest] {NoAI:1b,Silent:1b,Invulnerable:1b}leaves the nearest villager still, silent and impossible to hurt. It's the shopkeeper or the guide at a spawn.Giving it a name
/data merge entity @e[type=minecraft:zombie,limit=1,sort=nearest] {CustomName:"Boss",CustomNameVisible:1b}. Since 1.21.5 the name goes like this, in quotes; in earlier versions it was a JSON text inside another set of quotes.Making it glow or float
{Glowing:1b}makes it visible through walls and{NoGravity:1b}leaves it floating where it is.A spawner
/data merge block 100 64 -200 {SpawnData:{entity:{id:"minecraft:skeleton"}},Delay:20}switches it to skeletons and spawns the next one in a second. To set every option at once, there's the spawner command generator.
Players can't be changed
/data merge entity Ana {…} answers «Unable to modify player data». It's on purpose: a player's data can only be read.
To change something on them there's a command for each thing: healing, hurting or giving effects with /effect (its guide), experience with /xp (its guide), items with /give and /clear, position with /tp and max health or speed with /attribute (its guide).
Touching a single tag: /data modify
modify changes only what's at one path and can copy data from one place to another, which merge can't. After the path comes what to do: set (put), merge (mix), append and prepend (add at the end or the start of a list) or insert with a number (put it at that position).
Setting a value
/data modify entity @e[type=minecraft:villager,limit=1,sort=nearest] CustomName set value "Shopkeeper".Copying from somewhere else
/data modify entity @e[type=minecraft:armor_stand,tag=marker,limit=1] Pos set from entity Ana Posmoves the tagged armor stand to where Ana is. Copying from a player works; writing to one doesn't.Adding to a list
/data modify entity @e[type=minecraft:zombie,limit=1,sort=nearest] Tags append value "boss"adds the «boss» tag to it (the same as/tag … add boss), so you can pick it later with@e[tag=boss].Removing a tag
/data remove entity @e[type=minecraft:zombie,limit=1,sort=nearest] CustomNametakes its name away. With/data remove, the path is required: it doesn't wipe everything at once.
Your own variables with storage
storage is a place to keep your own data, with no chests or entities involved. You give it a name with a colon: /data modify storage myserver:event round set value 1 saves «round» and /data get storage myserver:event round reads it.
It's saved with the world, so it's still there after restarting the server. It's what datapacks and functions use to remember things between games (the datapacks guide).
With /execute and scoreboards
What /data get reads can be stored in a scoreboard: execute store result score @s health run data get entity @s Health puts your health into the «health» objective (create it first with /scoreboard objectives add health dummy). That's how you get a health display in the tab list or a warning when someone is low (the /execute guide).
The number you can put after the path multiplies what's read before storing it: data get entity @s Pos[1] 10 gives the height with one decimal folded into the whole number. It only works with numbers; with anything else, the game says «only numeric tags are allowed».
To run it every so often, put it in chained command blocks or in a datapack function.
The usual errors
«Found no elements matching …»: that path doesn't exist on that mob or block. Look at everything first with /data get entity … with no path and copy the name exactly as it appears, capital letters included.
A selector that picks more than one: add limit=1. And if it picks nobody, the mob isn't loaded or the type is misspelled (it goes with minecraft: in front).
A command copied from an old video that does nothing: most likely it's from before 1.21.5, when names and equipment were written differently. The /summon generator writes the tags for each version and they work the same with /data merge.
On NapNodes
Minecraft servers run Paper on the latest version, so everything in this guide applies. From the panel's «Console» you run any /data without the slash, even if you're not logged in; with entity and a player's name, they need to be online.
Before changing things in bulk with /data on a paid server, make a backup in «Backups»: if a merge goes wrong, you go back to how it was. The free server has no backups, so there try it on a single mob first.
Frequently asked questions
What is the /data command for in Minecraft?
For reading and changing the NBT data of mobs, blocks with data (chests, signs, spawners) and a storage of your own. Players can only be read.
How do I remove a mob's AI with /data?
With /data merge entity, the mob picked with limit=1 and {NoAI:1b}. For example, /data merge entity @e[type=minecraft:villager,limit=1,sort=nearest] {NoAI:1b}.
Why does /data say «Unable to modify player data»?
Because players' data can only be read. To change something on them you use the command for each thing: /effect, /xp, /give, /clear, /tp or /attribute.
How do I see what's in a chest with commands?
With /data get block and its coordinates followed by Items, for example /data get block 100 64 -200 Items.
What's the difference between /data merge and /data modify?
merge mixes several tags at once with what it already has; modify touches a single path and can also copy data from another entity, block or storage.
What is /data storage?
A data store of your own, with a name like myserver:event, that's saved with the world. It works as variables for datapacks, functions and command blocks.
Shall we set it up for you?
Minecraft servers from €6 a month, never oversold: your RAM is yours alone. And if you'd rather start without paying, there's a free Minecraft server, no card needed.
Your server doesn't show up in the game? Check it in a second with “Is my Minecraft server online?”: players, version and MOTD, free. Need a player's UUID for the whitelist or permissions? Look it up here. Handing out enchanted items? Build the command with the /give generator.
Free tool: Spawner command generator. A spawner with the mob you want (or several), how often and how many spawn and in what light: the /setblock or /give for your version.
Keep reading
- The /item command in Minecraft: put a block on your head, fill chests and change items
How to use /item in Minecraft Java: put a block on your head, dress up mobs, fill a chest, copy another player's item and what's new in 26.3.
- The /setblock Command in Minecraft: Place a Block Facing the Right Way, Filled Chests and Redstone
How to use /setblock in Minecraft Java: place or remove a block, which way it faces, chests with items, command blocks, destroy, keep and the usual errors.
- The /advancement and /recipe commands in Minecraft: give or take advancements and recipes
How to give or take advancements with /advancement and unlock all recipes with /recipe in Minecraft Java, without flooding the chat, or to reset an event.