Skip to main content
← All Guides
Commands

How to Give XP With Commands in Minecraft

The /xp command adds experience to any player instantly. Pick levels to bump the number above the hotbar, or points to fill the bar by a precise amount. Below is the full syntax with selectors, removal, and querying.

server console, server.jar
> /xp add @p 30 levels
[Server] Gave 30 levels to Steve
30
experience bar full · level up
> /xp add @p 500 points
[Server] Gave 500 experience points to Steve
The full /xp syntax

The command is /xp add|set|query <target> <amount> [levels|points]. add changes the amount relative to what a player already hasset overwrites it, and query reads it back.

<target> accepts a player name or a selector: @p nearest player@s yourself@a all players@r a random player. Negative amounts with add subtract, e.g. /xp add @p -3 levels.

Leaving off the last word defaults to points on legacy versions, so always state levels or points to avoid surprises. The whole command also works under its long name /experience.

Quick answers

+

What is the command to give XP in Minecraft?

Use /xp add <target> <amount> levels for levels, or /xp add <target> <amount> points for raw experience. Example: /xp add @p 30 levels.
+

What is the difference between levels and points?

levels gives whole experience levels (the number above the hotbar). points gives raw XP that fills the bar partway. 30 levels is far more XP than 30 points.
+

How do I give XP to all players?

Use the @a selector: /xp add @a 50 levels gives every online player 50 levels at once.
+

How do I remove or reset a player's XP?

Subtract with a negative amount like /xp add @p -10 levels, or wipe completely with /xp set @p 0 levels and /xp set @p 0 points.
+

Is /experience the same as /xp?

Yes. /experience is the full command and /xp is its built-in shorthand alias. Both accept the same add, set, and query arguments.
+

Why does the /xp command not work?

Cheats must be enabled, or you must be opped. On a server run /op YourName from the console first; in single-player open the world to LAN with cheats allowed.

/xp at a glance

Syntax

/xp <add|set|query> <targets> <amount>…

Who may run it

OP (L2)

What it does

Adds, sets, or queries experience points or levels for one or more players. This is an alias for /experience.

Three things /xp is actually used for

/xp add @s 30 levels
Adds thirty levels, enough for a full enchanting table roll at level thirty.
/xp set @s 0 levels
Wipes your experience back to zero without killing you.
/xp query @s levels
Prints your current level in chat instead of changing anything.

/xp sits with the player commands in Minecraft, 12 of them in total. The ones with a guide here: /effect, /enchant, /experience, /gamemode, /give, /teleport, /tp.

Every command with its full argument list lives in the command reference.

Blocks and items in this guide

Diamond in MinecraftDiamondTarget in MinecraftTarget

All 2 of these are named in the guide above, starting with Diamond. Look them up in the item database.

More guides on this site

Guides that go with this one

How to Use the /give Command in Minecraft
Spawn any item with /give @p diamond 64, selectors, counts, and 1.20.5+ item components for custom...
How to Use the /effect Command in Minecraft
Give, clear and stack status effects with the /effect command: full syntax for /effect give @p speed 60...
How to Use the /gamemode Command in Minecraft
<> One command swaps a player between Survival, Creative, Adventure and Spectator. Learn the full...
How to Change the Time With Commands in Minecraft
Use /time set day, night, and midnight plus /time add to control the day-night cycle on your Minecraft...
How to Change the Weather with Commands in Minecraft
Use /weather clear, /weather rain or /weather thunder to set the sky instantly. Add a duration in...
How to Use /gamerule Commands in Minecraft
Toggle Minecraft gamerules from the console: keepInventory, doDaylightCycle, mobGriefing and more. Real...
Database
Command Reference
Syntax, arguments and examples for every command.
Hosting
Managed Hosting
Skip the setup: a managed server online in minutes.
Database
Item Database
Every item with its stats, IDs, recipes and uses.
Guides
More Server & Admin guides
Run a server: setup, hosting, permissions, worlds and crossplay.