How to enable cheats in Minecraft after creating the world

Turn on cheats in a world you already created: open it to LAN with Allow Cheats on (Java), or switch on the permanent allowCommands setting in level.dat.

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

  1. Load the world and press Esc.
  2. 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.
  3. 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.

level.dat with commands allowed
  • { }Data
    • BallowCommands1
    • IGameType0
    • StrLevelName"My survival world"
  1. Close Minecraft and copy the world folder as a backup.
  2. Open the world's level.dat in the editor.
  3. Expand Data and set allowCommands to 1.
  4. Download the file and replace level.dat in the world folder.
  5. Load the world and type /gamemode creative or 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 like keep_inventory; older versions use keepInventory. Game rules without commands covers editing them in the file.
  • Inspect your own data with /data get entity @s, which prints it as SNBT.

Ready to edit?Open the file in the editor: every value keeps its NBT type and the file is saved in its original format.