Minecraft · Wiki · Command

/xp

Adds or sets experience.

TypeCommand

Data checked Oct 21, 2026

The /xp command, called /experience in Java Edition, adds, removes, sets or checks a player’s experience. Experience powers enchanting, anvils and Mending repairs, so being able to control it is useful for testing enchantments, rewarding players on servers and setting up adventure maps. This command reference covers the syntax in Java and Bedrock, the difference between points and levels, how much experience each level needs, examples and common errors.

Syntax

Use Java Bedrock
Add points /xp add <targets> <amount> points /xp <amount> [player]
Add levels /xp add <targets> <amount> levels /xp <amount>L [player]
Remove levels /xp add <targets> -<amount> levels /xp -<amount>L [player]
Set /xp set <targets> <amount> [points|levels] Not available directly
Check /xp query <target> <points|levels> Not available directly

In Java, /xp and /experience are the same command. If you leave out points or levels, Java assumes points. In Bedrock, adding an L after the number means levels; without it, the number is experience points. Bedrock cannot remove points, only levels with a negative number.

Points vs levels

Experience points are what you collect from orbs. Levels are the number shown above your hotbar. Each level needs more points than the last, so giving 100 points to a level 0 player raises them several levels, but the same 100 points barely moves a level 40 player. Enchanting tables and anvils spend levels, while Mending repairs consume points from orbs.

How many points per level?

Level range Points needed for the next level
0 to 15 2 times the level plus 7
16 to 30 5 times the level minus 38
31 and up 9 times the level minus 158
Level Total points from zero
5 55
10 160
15 315
20 550
30 1,395
40 2,920
50 5,345

Level 30 is the target most players aim for, because it unlocks the best enchanting table offers.

Examples

Command Result
/xp add @s 30 levels Java: add 30 levels to yourself
/xp 30L Bedrock: add 30 levels to yourself
/xp add @a 500 points Java: 500 experience points for everyone
/xp 500 @a Bedrock: 500 points for everyone
/xp set @s 0 levels Java: reset your level to 0
/xp -100L @s Bedrock: remove all your levels
/xp query @s levels Java: show your current level
/xp add Steve -5 levels Java: take five levels from Steve

Practical uses

  • Testing enchantments: give yourself 30 levels and lapis to try the enchanting table. See books and bookshelves for setting up a level 30 table.
  • Anvil experiments: check what combinations cost before doing them in Survival; see how to use an anvil.
  • Server rewards: give levels for winning events or completing quests.
  • Adventure maps: use levels as currency or as a timer shown on the XP bar.
  • Resetting: clear levels at the start of a challenge.

Getting experience in Survival

Without commands, experience comes from killing mobs, mining ores such as coal, diamond, emerald, lapis, redstone and nether quartz, smelting items, breeding animals, trading with villagers, fishing and bottles of enchanting. The fastest sources are mob farms, especially enderman farms in the End and guardian farms at ocean monuments, plus spawner farms. See the enderman page for enderman farm ideas.

Experience and death

When you die without keepInventory, you drop some of your experience as orbs, up to a limited amount, and the rest is lost. That is why high-level players spend their levels on enchanting before risky adventures. With keepInventory on, you keep all experience. See the /gamerule page.

Mending and experience

Items with Mending use experience orbs you pick up to repair themselves before the points go to your level bar. Each experience point repairs two durability points. Holding a damaged Mending tool at an XP farm repairs it for free, which is why XP farms and Mending go together.

Permissions

/xp requires cheats or operator permission. In Bedrock, using commands disables achievements for that world.

Common errors

  • Bedrock /xp does nothing: you typed levels without L, so it added points; add L after the number.
  • Cannot remove points in Bedrock: only levels can be removed.
  • Java set fails with points: you cannot set more points than the current level allows; set levels first.
  • No player found: check the name or selector.

Related commands

  • /enchant: enchant without spending levels.
  • /give: give bottles of enchanting.
  • /gamerule: keepInventory keeps your levels after death.

/xp FAQ

How do you give yourself levels in Minecraft?

Java: /xp add @s 30 levels. Bedrock: /xp 30L.

How many points is level 30?

1,395 experience points from zero.

How do you remove levels?

Use a negative number: /xp add @s -10 levels in Java or /xp -10L in Bedrock.

Is /experience the same as /xp?

Yes, in Java.

Why higher levels cost more

Because each level needs more points than the one before, experience gets less efficient as you level up. Going from level 0 to 30 takes 1,395 points, but going from 30 to 40 takes another 1,525 points, more than the whole first thirty levels. This is why experienced players spend levels often instead of hoarding them: an enchanting table always costs at most three levels for a level 30 offer, so dropping from 33 to 30 costs far fewer points than climbing back from 3 to 6 would. The most efficient habit is to enchant at around level 30 to 33 and repeat, rather than saving up to level 100.

Experience in multiplayer

On servers, experience is personal: each player has their own level and orbs go to whoever picks them up. XP farms are often shared, so communities set rules about taking turns. Operators can use /xp to compensate players who lost levels to bugs or lag deaths, or to give event rewards fairly. Using selectors such as @a[team=winners] makes it easy to reward a whole team at once.

Bottles of enchanting

Bottles of enchanting are thrown items that release experience orbs when they break. Cleric villagers sell them, and they appear in some loot chests. They are a portable experience source for repairing Mending gear on the go or topping up levels before enchanting. Give yourself a stack with /give @s experience_bottle 64 in a test world to see how quickly they repair items.

Experience from smelting and breeding

Smelting gives experience when you take items out of a furnace, with ores and food giving the most. Breeding animals gives a little experience each time. Trading with villagers also gives experience, which makes large trading halls a surprisingly good XP source over time. These small sources add up in Survival and do not require fighting mobs.

Checking someone’s level

In Java, /xp query with a player name and levels shows their current level in chat, which is useful for server staff and for scoreboard systems that track progress. In Bedrock there is no query option, so players check the number above their hotbar instead, or map makers use the scoreboard to track experience in other ways.

Quick reference

For the two most common jobs, remember these: to reach the best enchanting level, use /xp add @s 30 levels in Java or /xp 30L in Bedrock; to reset a player for a challenge, use /xp set @s 0 levels in Java or /xp -1000L in Bedrock. Everything else on this page builds on those two patterns.

Both editions show your level as a green number above the hotbar, which updates instantly after any /xp command.

That makes results easy to check.

Happy enchanting.

For more on spending levels well, see the enchanting and anvil guides linked above.

More about Minecraft

See all