Short answer: in Java Edition, load the world, press Esc, choose Open to LAN, turn Allow Cheats on and click Start LAN World. Commands work until you leave. To keep cheats on for good, set allowCommands to 1 in the world's level.dat, as shown below. In Bedrock, the Cheats switch stays available in the world settings.
Cheats (the ability to use commands such as /gamemode, /tp or /gamerule) are chosen when you create a Java world, and the world options screen doesn't let you change that choice later. There are two ways around it: a temporary one inside the game, and a permanent one in the world's level.dat.
One-click way for the permanent fix: close the game, open the world's level.dat in the editor, and switch on Allow cheats (commands) under Fix this world in the Visual tab.
Temporary: open the world to LAN
- Load the world and press Esc.
- Click Open to LAN, turn the commands option ON (it reads Allow Cheats or Allow Commands depending on your version), then start the LAN world.
- Commands work until you leave the world. Next time you load it, cheats are off again.
This is enough for a one-off fix, such as getting out of a hole with /tp or switching back to Survival. If you want commands every time, change the setting in the file.
Permanent: set allowCommands in level.dat
The world's cheat setting is a single Byte, BallowCommands, directly inside Data. It has kept the same name and place through the 1.21 updates and the 26.1 storage changes.
- { }Data
- BallowCommands1
- IGameType0
- StrLevelName"My survival world"
- Close Minecraft and copy the world folder as a backup.
- Open the world's
level.datin the editor. - Expand
Dataand setallowCommandsto1. - Download the file and replace
level.datin the world folder. - Load the world and type
/gamemode creativeor any other command to check.
To turn cheats off again, set it back to 0.
Does it affect advancements?
In Java Edition, no. Advancements and statistics keep working with commands allowed; the world list simply notes that cheats are on.
Bedrock Edition is different: turning cheats on disables achievements for that world, and they don't come back when you turn cheats off.
Bedrock Edition
Bedrock lets you toggle Activate Cheats in the world settings at any time, so editing the file is rarely needed. The setting is stored in Bedrock's own level.dat as BcommandsEnabled. The Bedrock level.dat guide explains how that file differs from the Java one.
Servers
A dedicated server doesn't use allowCommands to decide who may run commands. Give yourself operator status instead, with op YourName in the server console. Operators are listed in ops.json next to the server jar.
What else you can do once cheats are on
- Change game rules with
/gamerule. From Java 1.21.11 the names are written likekeep_inventory; older versions usekeepInventory. Game rules without commands covers editing them in the file. - Inspect your own data with
/data get entity @s, which prints it as SNBT.