Thirty levels for enchanting
/xp add @s 30 levelsGives you 30 levels, enough for the best enchanting table offers.

/experience, also available as /xp, adds, removes, sets or reads a player's experience, counted in levels or in points. Use it to prepare enchanting tests, refund players on a server or read levels inside a command system.
/experience add <target> <amount> [levels|points]/experience query <target> (levels|points)/experience set <target> <amount> [levels|points]/experience add/experience add <target> <amount> [levels|points]| Argument | Expects | What it does |
|---|---|---|
| target | Player selectorone or several | Players whose experience changes: @s, @p, @a or a name. query accepts only one player. |
| amount | Whole number | Number of levels or points. With add it can be negative to remove experience. |
/experience query/experience query <target> (levels|points)| Argument | Expects | What it does |
|---|---|---|
| target | Player selectorone | Players whose experience changes: @s, @p, @a or a name. query accepts only one player. |
/experience set/experience set <target> <amount> [levels|points]| Argument | Expects | What it does |
|---|---|---|
| target | Player selectorone or several | Players whose experience changes: @s, @p, @a or a name. query accepts only one player. |
| amount | Whole numberat least 0 | New value, 0 or more. In points, it cannot go past the bar of the current level. |
/xp add @s 30 levelsGives you 30 levels, enough for the best enchanting table offers.
/experience add @a 100Without a unit, every player receives 100 experience points.
/xp add @p -5 levelsA negative amount removes five levels from the nearest player.
/experience set @s 0 levelsSets your level to 0 without touching the progress inside the bar.
/experience query @s levelsPrints your current level in the chat.
/execute store result score @s levels run xp query @s levelsStores your level in the levels objective, which must already exist.
Fill in the fields, copy the command, paste it in the chat. Syntax checked against Java Edition 26.3.
Turn on JavaScript to use the interactive version.
/experience add @p 30 levelsCalculated from the Java Edition 26.3 game files
Points fill the green bar, levels are the number above it. Without a unit, the command uses points. Adding enough points raises the level, and a negative amount with add takes experience away. set only accepts 0 or more, and setting points above the current bar fails with "Cannot set experience points above the maximum points for the player's current level".
The best offers of the Enchanting Table need level 30, and repairs on an Anvil also cost levels, so /xp add @s 30 levels is the quickest setup for a test. Mending and the Bottle o' Enchanting work with points instead.
query returns the level or the points of one player. With /execute and store result score, the value goes into a /scoreboard objective that you can test or display. For a simple reward, /give can also hand out Bottles o' Enchanting.
✓ Checked in Java Edition 26.3 · updated 2 November 2026
Yes. /xp is an alias and takes exactly the same sub-commands and arguments.
Use add with a negative amount, for example /xp add @p -5 levels, or set the exact value with /xp set @p 0 levels.
Type it in the chat with cheats on: /experience add <target> <amount> [levels|points].
Cheats on, or operator level 2.