Editing Game Rules in level.dat

Supports Minecraft Bedrock Edition and Java Edition — and every server core for both, popular or obscure: Vanilla, Paper, Spigot, Purpur, Folia, Fabric, Forge, NeoForge, Mohist, Sponge, Bedrock Dedicated Server, PocketMine-MP, Nukkit, PowerNukkitX, Cloudburst, Dragonfly, Endstone, LeviLamina and the rest. Full list.

Game rules are stored in level.dat, so you can change them without loading the world or having cheats enabled — useful when a world will not start, when cheats are off, or when you are preparing a copied world before players join. Java keeps them in a GameRules compound as strings; Bedrock keeps each one as its own lowercase byte tag at the root.

keepInventorydoDaylightCyclemobGriefingcommandBlockOutputrandomTickSpeed

Drop level.dat here

level.dat · .nbt · .mcstructure · .schem · .schematic · .dat · chunk dumps

Java: a GameRules compound of strings

In Java Edition, Data → GameRules holds one TAG_String per rule, keyed by the exact name /gamerule uses, with the value written as text: "true", "false" or a number. Rules the world has never set are simply absent and fall back to their defaults — adding the tag with the correct name and a string value works exactly like running the command.

RuleValueEffect
keepInventory"true"Keep items on death
doDaylightCycle"false"Freeze the time of day
doWeatherCycle"false"Freeze the weather
mobGriefing"false"Stop creepers and endermen changing blocks
doMobSpawning"false"Stop natural mob spawning
doFireTick"false"Fire stops spreading
commandBlockOutput"false"Silence command block chat spam
randomTickSpeed"3"Crop growth and fire spread rate
playersSleepingPercentage"50"Share of players needed to skip the night
spawnRadius"10"Spread of the spawn area

Case matters. keepinventory in a Java file is not the same tag as keepInventory and will be ignored.

Bedrock: individual lowercase byte tags

Bedrock does not group rules. Each one is a TAG_Byte at the root of level.dat, named in lowercase, holding 1 or 0 — keepinventory, domobspawning, domobloot, dodaylightcycle, doweathercycle, mobgriefing, firedamage, falldamage, drowningdamage, pvp, showcoordinates, commandblockoutput, sendcommandfeedback, naturalregeneration, tntexplodes, respawnblocksexplode, showdeathmessages, doimmediaterespawn. Numeric rules such as randomtickspeed and functioncommandlimit are TAG_Int instead.

Setting a rule that is not yet present means adding the tag with the right type: Byte for a toggle, Int for a number. A rule stored with the wrong type is ignored, or refuses to load.

When editing the file beats the command

  • Cheats are off and you do not want to toggle them on and off to run one command.
  • The world will not load — a rule such as doImmediateRespawn can be set before the first join.
  • You are preparing a template world to be copied for many servers, and want the rules baked into the copy.
  • A plugin changed a rule and you want to see what is actually stored rather than what a command reports.
  • Bulk edits. Setting a dozen rules across several worlds is faster in the file than in chat.

Stop the server first, as with any level.dat edit — a running world rewrites the file on save and will discard the change.

Frequently Asked Questions

Why is my game rule stored as a string in Java?

Java's game rule storage is string-based for every rule, including booleans and numbers. Write "true", not a byte of 1.

Why is it a byte in Bedrock?

Bedrock stores toggles as byte tags at the root and numeric rules as ints. There is no GameRules compound.

A rule is missing from the file entirely.

That means it is at its default. Add the tag with the exact name and correct type and the world will use your value.

Do game rules copy with a world folder?

Yes — they live in level.dat, so a copied world inherits them along with its stale world name.

Related tools