Java Edition · 1.21+

Minecraft Java Commands Guide

Copy-ready commands for survival, creative builds, and servers — teleport, give items (modern components), locate structures, gamerules, fill/clone, and execute. Not a dump of every obscure command: the ones people actually use.

Prefer clicking over typing?

Build give / summon / effect commands in the generator, then paste into chat.

Open command generator

How to enable cheats

Existing world

  1. Esc → Open to LAN
  2. Allow Cheats: ON
  3. Start LAN World

Session only — redo after relaunch.

New world

  1. Create New World
  2. Allow Cheats: ON
  3. Create

Cheats stay on permanently.

Multiplayer server

In the server console: op YourName

Command blocks need enable-command-block=true in server.properties.

Quick cheat sheet

One-tap copies for the commands people search most. Paste in chat (cheats/OP required).

Target selectors

Selectors pick who a command hits. Add filters in brackets: @e[type=zombie,distance=..15,limit=5]

SelectorMeansExample
@sYourself (executor)/gamemode creative @s
@pNearest player/tp @p ~ ~5 ~
@aAll players/effect give @a speed 30 1
@rRandom player/tp @r @s
@eAll entities/kill @e[type=item]

Useful filters: type=, distance=.., name=, gamemode=, limit=, sort=nearest.

Syntax basics

/command <required> [optional] @selector[filters]
  • Always start with / in chat.
  • Relative coords: ~ = current position, ~5 = five blocks offset.
  • IDs are lowercase: diamond_sword, not Diamond_Sword.
  • Items (1.20.5+): components in [brackets] — not old {Enchantments:} on /give.

Command reference

Java Edition 1.21+ syntax. Search or filter by category — click any example to copy.

Essentials

The commands most players open chat for first.

Gamemode

/gamemode <survival|creative|adventure|spectator> [player]

Switch game mode for yourself or another player.

Teleport

/tp <destination> · /teleport …

Move players or entities to coordinates, another entity, or another dimension.

Relative coords use ~. Facing: /tp @s 0 70 0 facing 10 70 10

Give

/give <player> <item>[components] [count]

Spawn items into a player’s inventory. Modern Java uses item components in [brackets].

Pre-1.20.5 worlds used {Enchantments:[…]} NBT. Prefer components on current Java.

Locate

/locate structure <id> · /locate biome <id>

Find the nearest structure or biome and print coordinates (chat clickable).

Old /locatebiome is gone — use /locate biome. Surface sulfur springs are not a separate biome, so /locate won’t find them.

Seed

/seed

Shows the world seed (needed for seed maps and sharing worlds).

Enchant

/enchant <targets> <enchantment> [level]

Adds an enchantment to the item currently held in the main hand. Caps at vanilla max levels.

For over-level enchants or multiple at once, use /give with enchantments={levels:{…}} instead.

Clear

/clear [targets] [item] [maxCount]

Remove items from inventories. No item = clear everything.

Spawnpoint

/spawnpoint [targets] [pos] [angle]

Set a player’s personal respawn point (like sleeping in a bed).

Setworldspawn

/setworldspawn [pos] [angle]

Set the world spawn where new players and unbedded deaths appear.

Kill

/kill [targets]

Remove entities. Be careful with @e — it includes you unless filtered.

Help

/help [command]

In-game syntax help for any command.

World & player state

Time, weather, effects, and gamerules.

Time

/time set <day|night|noon|midnight|ticks>

Set or query world time.

Weather

/weather <clear|rain|thunder> [durationSeconds]

Force weather. Duration is in seconds on modern Java.

Effect

/effect give <targets> <effect> [seconds] [amplifier] [hideParticles]

Apply or clear status effects. People search this for night vision, strength, and “god mode”.

Gamerule

/gamerule <rule> [value]

Toggle world rules used by servers and map makers.

Difficulty

/difficulty <peaceful|easy|normal|hard>

Set world difficulty.

Worldborder

/worldborder set <diameter> [seconds]

Shrink or expand the playable area (UHC, events, SMP borders).

Xp

/xp add <targets> <amount> [points|levels] · /experience …

Add or set experience points/levels.

Attribute

/attribute <target> <attribute> <get|base set|modifier …>

Read or change entity attributes (speed, health, scale, etc.).

Older worlds used minecraft:generic.max_health — tab-complete the current ID.

Recipe

/recipe <give|take> <targets> <recipe|* >

Unlock or revoke crafting recipes in the recipe book.

Advancement

/advancement <grant|revoke> <targets> <everything|only|…>

Give or remove advancements (achievements).

Building & entities

Fill, clone, summon, place — map-maker and creative tools.

Fill

/fill <from> <to> <block> [destroy|hollow|keep|outline|replace]

Place or replace blocks in a box (hard limit ~32,768 blocks per command).

Clone

/clone <from> <to> <destination> [replace|masked|filtered] [force|move|normal]

Copy a region of blocks to a new spot.

Summon

/summon <entity> [pos] [nbt]

Spawn entities. Extra data still uses SNBT braces {…}.

Place

/place structure|feature|jigsaw|template …

Generate a vanilla structure or feature at a position (great for testing).

Setblock

/setblock <pos> <block> [destroy|keep|replace]

Place a single block.

Loot

/loot <give|insert|spawn|replace> …

Roll a loot table into inventory, a chest, or the world.

Item

/item replace|modify …

Put items into slots (players, armor stands, chests). Replaces old /replaceitem.

Spreadplayers

/spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <targets>

Scatter players randomly on the map (UHC / event starts).

Particle

/particle <name> <pos> [delta] [speed] [count]

Spawn particles for effects and map juice.

Playsound

/playsound <sound> <source> <targets> [pos] [volume] [pitch]

Play a sound to players.

Ride

/ride <target> <mount|dismount> …

Make one entity ride another (Happy Ghast, boats, custom mounts).

Damage

/damage <target> <amount> [damageType] [at|by …]

Deal exact damage for testing farms, armor, and PvP setups.

Advanced & map making

Execute, scoreboards, titles, teams, and bossbars.

Execute

/execute <…subcommands…> run <command>

The power tool: change dimension, position, conditions, then run another command.

Chain: as → at → if/unless → run. Tab-complete is your friend.

Scoreboard

/scoreboard objectives … · /scoreboard players …

Track stats, money systems, minigame scores, and triggers.

Team

/team <add|remove|join|leave|modify|list|empty> …

Friendly fire, nametag colors, and collision rules for PvP/minigames.

Since 26.2, colors like darkpurple or DarkPurple fail — use dark_purple (same as text component names).

Waypoint

/waypoint list · /waypoint modify <targets> color|style …

Manage locator-bar waypoints (player/mob dots). Colors follow the same underscore rules as teams in 26.2.

Tag

/tag <targets> <add|remove|list> [name]

Label entities for selectors like @e[tag=boss].

Tellraw

/tellraw <targets> <json>

Rich chat messages with colors, click events, and hover text.

Title

/title <targets> <title|subtitle|actionbar> <json>

Big on-screen text for events and maps.

Bossbar

/bossbar add <id> <name>

Custom bars at the top of the screen (timers, bosses, events).

Spectate

/spectate [target] [player]

Force a spectator to follow an entity (replay cams, death cams).

Forceload

/forceload <add|remove|query> …

Keep chunks loaded without players nearby (farms, redstone).

Data

/data get|merge|modify|remove …

Read or edit NBT on blocks, entities, and storage.

Function

/function <namespace:path>

Run a .mcfunction from a datapack (many commands at once).

Tick

/tick <query|rate|step|freeze|unfreeze|sprint>

Control game tick rate for debugging farms and redstone (1.20.3+).

Server admin

Ops, whitelist, bans — multiplayer essentials.

Op / Deop

/op <player> · /deop <player>

Grant or revoke operator permissions.

Whitelist

/whitelist <on|off|add|remove|list|reload>

Restrict who can join.

Ban / Pardon

/ban <player> [reason] · /pardon <player>

Kick permanently or reverse a ban.

Kick

/kick <player> [reason]

Remove a player from the server without banning.

List

/list [uuids]

Show who is online.

Defaultgamemode

/defaultgamemode <mode>

Mode new players get when they join.

Save / Stop

/save-all · /stop

Flush world save or shut down the server safely.

Say / Tell

/say <message> · /tell <player> <message>

Broadcast or whisper.

FAQ

How do I enable cheats in an existing Minecraft Java world?

Pause → Open to LAN → Allow Cheats: ON → Start LAN World. Cheats stay on for that session. For a permanent fix, use an NBT editor on level.dat or recreate with cheats on. On servers, you need OP (/op yourname in the console).

What’s the difference between @p, @a, @s, @e, and @r?

@p = nearest player, @a = all players, @s = the entity running the command (usually you), @e = all entities (mobs, items, players…), @r = random player. Add filters like @e[type=zombie,distance=..20].

Why does my /give enchanted sword command fail?

On Java 1.20.5+, item NBT like {Enchantments:[…]} was replaced by item components in square brackets, e.g. /give @s diamond_sword[enchantments={levels:{sharpness:5}}]. Old brace syntax is for entity/block data, not modern /give.

How do I find a stronghold or fortress with commands?

Use /locate structure minecraft:stronghold or /locate structure minecraft:fortress. Click the coordinates in chat to suggest a /tp. Biomes use /locate biome minecraft:desert (not the old /locatebiome).

How do I teleport to the Nether or the End?

Use execute’s dimension subcommand: /execute in minecraft:the_nether run tp @s ~ 100 ~ or /execute in minecraft:the_end run tp @s 0 100 0. Same X/Z scale as the Overworld unless you convert coords yourself.

Why isn’t /fill working?

Regions larger than 32,768 blocks fail. Shrink the box, or fill in chunks. You also need permission (cheats/OP) and valid block IDs (stone, not Stone).

Do these commands work on Bedrock?

Many names match, but syntax, selectors, and item components differ. This guide is Java Edition only. Bedrock often uses different /give format and lacks some execute features.

How do I keep my inventory when I die?

Run /gamerule keepInventory true. It applies to the whole world/server until you set it false again.

How do I enchant the item in my hand?

Hold the item and run /enchant @s sharpness 5 (or efficiency, mending, fortune, etc.). Levels cap at vanilla maxima. For custom/overpowered enchants use /give with enchantments={levels:{…}}.

How do I clear my inventory with a command?

/clear @s empties everything. /clear @s diamond removes only diamonds. Add a number at the end to limit how many are taken.

How do I set my spawn / world spawn?

/spawnpoint @s sets your personal bed-like spawn. /setworldspawn sets where new players and players without a bed appear.

Is there a /home or /warp command in vanilla?

No — those come from plugins (Spigot/Paper) or datapacks. Vanilla alternatives: /spawnpoint, /setworldspawn, /tp to saved coords, or a datapack that adds homes.

CraftMC

Your ultimate resource for Minecraft tools and guides.

Professional ToolsExpert GuidesActive Support

Popular Tools

Quick Links

Also from us

We also run a Fortnite tools site — free calculators, weapon guides, map drops, and season helpers.

Visit FortniteTools.com

© 2026 CraftMC. All rights reserved. Also check out our Fortnite tools site.