How To Lock Your Minecraft Chests With One Simple Command! (Updated)

Video Summary
In this video I show you how to lock a chest in Minecraft Java Edition using a single command—no mods or datapacks needed. After placing a chest and enabling cheats, you use a data merge command with a custom Lock name while looking at the block. To open it, you simply rename any item in an anvil to match the lock name and use it as the key, and this also works on shulker boxes. I also explain the limitation: breaking the container drops the items and removes the lock, so it’s most effective in adventure mode, and it doesn’t work on Bedrock Edition.

Formatted Transcript

Hey everybody, it’s Under My Cap, and welcome back. Today I’m going to show you how to make a locked chest in Minecraft: Java Edition. This doesn’t use any mods or data packs—just a single command.

You’ll end up with a chest that looks completely normal, but when you click it, you won’t be able to open it. Instead, it will tell you the chest is locked. The best part is that it works in both Creative and Survival; you simply need a special “key” item with a specific name to unlock it.

Before You Start: Enable Cheats

To do this, you need cheats enabled in your world.

If your world doesn’t already have cheats enabled, you can turn them on by opening the pause menu and selecting Open to LAN, then setting Allow Cheats to ON, and clicking Start LAN World.

Step 1: Place the Chest

Go into Creative mode (optional, but easier for setup), place down a regular chest, and make sure it’s the exact block you want to lock.

Step 2: Lock the Chest with One Command

This part is important: you must be looking directly at the chest block when you run the command.

Open chat and type the following command, using your own lock name inside the quotation marks:

/data merge block (use the autofill coordinates while looking at the chest) {Lock:”YOUR LOCK NAME”}

For example, you could use:

{Lock:”hello this is a key”}

When you press Enter, you should see a message like “Modified block data.” Now, if you try to open the chest, it won’t open and will make the usual blocked/locked sound.

Note: You don’t need underscores. Spaces are fine, as long as the lock name is inside quotation marks.

Step 3: Make the Key Item

To unlock the chest, you’ll need an item renamed to match the lock name exactly.

Place an anvil down, choose any item you want to use as your key (for example, a water bottle), and rename it in the anvil to the exact same text you used in the lock.

Using the example above, rename the item to:

hello this is a key

Now, hold that renamed item in your hand and open the chest—it should unlock and open normally.

Works on More Than Just Chests

This also works on other containers. For example, you can apply the same method to a shulker box, and it will only open when you’re holding the correctly named key item.

Important Limitation: Breaking the Block

One downside is that if someone breaks the locked chest (or container), it will drop its contents and effectively bypass the lock. So this is best used in situations where players can’t break blocks (like Adventure mode), or where players don’t realize breaking it is an option.

Java Edition Only

Unfortunately, this method does not work on Bedrock Edition (at least not in the same way), so keep that in mind if you were hoping to use it there.

Thanks so much for watching, and I can’t wait to see you in the next video. See you later!

Video Thumbnail

Advertisment

Leave a Reply

Scroll to Top