Everything about a player lives in one NBT file: inventory, ender chest, position, health, hunger, experience, game mode. Editing it is the way to restore lost items, fix a broken inventory or move someone who can't log in, and it works when commands can't help. The /data command refuses to modify players.
The hard part is usually finding the right file. It moved in Java 26.1, and singleplayer has its own rules.
Where the player file is
| Situation | 1.21.11 and older | 26.1 and later |
|---|---|---|
| Server or LAN guest | world/playerdata/<uuid>.dat | world/players/data/<uuid>.dat |
| Singleplayer (the world's owner) | Inside level.dat: the Data › Player compound | players/data/<uuid>.dat, the UUID being singleplayer_uuid in level.dat |
Up to 1.21.11, a singleplayer world can contain both a Player compound in level.dat and a file in playerdata for the same person. The game uses the one in level.dat, so edit that one. Each player file also has a .dat_old twin: the previous save, useful as a fallback.
Find your UUID
Player files are named after the player's UUID, a 32-digit hexadecimal identifier written like 069a79f4-44e9-4726-a5be-fca90e38aaf5, not after the username.
- On a server: open
usercache.jsonnext to the server jar. It pairs recent usernames with UUIDs. - Online accounts: the UUID never changes, even when the name does, so any UUID lookup site works.
- Offline-mode servers use a different UUID calculated from the name, so the online one won't match. Use usercache.json.
- Singleplayer on 26.x: level.dat stores your UUID as four numbers in
I[ ]singleplayer_uuid. Paste them below to get the file name.
Result:
The tags that matter
- { }root
- StrDimension"minecraft:overworld"
- [ ]Posx, y, z as Doubles
- [ ]Rotationyaw, pitch as Floats
- FHealth20
- IfoodLevel20
- FfoodSaturationLevel5
- IXpLevel7
- FXpP0.25progress to next level, 0 to 1
- IXpTotal160
- IplayerGameType0
- [ ]Inventoryone compound per stack
- [ ]EnderItemssame format, 27 slots
- { }equipmentarmor and off hand (1.21.5+)
- { }abilitiesflying, mayfly, instabuild…
| To change | Edit | Notes |
|---|---|---|
| Game mode | IplayerGameType | 0 survival, 1 creative, 2 adventure, 3 spectator |
| Health | FHealth | 20 is ten full hearts. Max health can be higher with effects or attributes. |
| Hunger | IfoodLevel, FfoodSaturationLevel | 20 is a full bar |
| Experience | IXpLevel, FXpP, IXpTotal | Change XpLevel for the shown level; XpP is the bar's progress |
| Position | [ ]Pos, StrDimension | See moving a stuck player |
| Ender chest | [ ]EnderItems | Same item format as Inventory, slots 0 to 26 |
Inventory items
Each stack in [ ]Inventory is a compound. Since Java 1.20.5 a stack has an Strid, an Int Icount and an optional components compound for everything else: damage, enchantments, custom names. The BSlot tag places it: 0 to 8 is the hotbar from left to right, 9 to 35 the main inventory from the top-left corner.
- [ ]Inventory
- { }0
- BSlot0
- Strid"minecraft:diamond_sword"
- Icount1
- { }components
- Iminecraft:damage12
- { }minecraft:enchantments
- Iminecraft:sharpness3
- { }1
- BSlot9
- Strid"minecraft:diamond"
- Icount64
- { }0
To add a stack, open the ☰ menu on an existing item, choose Duplicate, then change its Slot, id and count in the copy. Duplicating keeps every tag's type, which is safer than building the compound from scratch. Remove the components compound from the copy if you don't want it. Two stacks must never share a Slot.
Armor and off hand
Since 1.21.5, worn armor and the off-hand item are in the { }equipment compound, under the keys head, chest, legs, feet and offhand. Each key holds one item compound without a Slot. Before 1.21.5 they were stored in Inventory with special slot numbers: 100 to 103 for the boots up to the helmet, and −106 for the off hand.
Enchantments
From 1.21.5 the minecraft:enchantments component maps each enchantment to its level, as in the figure above. Between 1.20.5 and 1.21.4 the map sat one level deeper, under a levels key. Levels above the vanilla maximum work up to 255.
Step by step
- Make sure the player is offline. On a server that is enough: it reads the file again when they join, so you don't need to restart it. For a singleplayer world, close the game.
- Back up the player file (and level.dat in singleplayer).
- Open the file in the editor. For singleplayer up to 1.21.11, open level.dat and expand
Data › Player. - Make your changes. The type badge before each name shows what kind of value it holds.
- Download and put the file back under exactly the same name. On a server, you can skip the download: mount its folder over SFTP, open it with Open folder and click Save to file.
- Start the game or server and log in to check.
If the player loses everything on login
When a player file can't be read, the game creates a fresh player: empty inventory at the world spawn. Don't play on. Close the game, restore your backup or the .dat_old copy, and look for the mistake. Common causes are a duplicated Slot number, an item id with a typo, or a list that mixes types; the editor reports the last one before you download.