/xp
Adds, sets, or queries experience points or levels for one or more players. This is an alias for /experience.
Overview
Adds, sets, or queries experience points or levels for one or more players. This is an alias for /experience. In vanilla Minecraft Java Edition it is one of the player commands and has been available since version 1.0.
It is invoked as /xp and accepts 3 required arguments (
/xp is an alias — /experience behaves identically, so you can use whichever you prefer.
The /xp command is functionally identical to /experience. Both are valid aliases in Java Edition.
Adding points can push a player up one or more levels; adding levels jumps the level number directly and tops up the bar to empty.
Syntax & Arguments
/xp <add|set|query> <targets> <amount> [levels|points]The full syntax is /xp . Angle brackets < > mark required arguments and square brackets [ ] mark optional ones; a vertical bar | between words means you pick exactly one of those literals. You must always supply
- action
- Required, of type a literal. The action to perform: add, set, or query.
- targets
- Required, of type an entity. The player(s) to modify.
- amount
- Required, of type an integer. The amount of experience. For add, can be negative. For query, this parameter is omitted.
- unit
- Optional, of type a literal. Whether the amount refers to levels or points. Defaults to points.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| action | literal | Required | The action to perform: add, set, or query. |
| targets | entity | Required | The player(s) to modify. |
| amount | integer | Required | The amount of experience. For add, can be negative. For query, this parameter is omitted. |
| unit | literal | Optional | Whether the amount refers to levels or points. Defaults to points. |
Examples
The 3 examples below are ready to copy and adapt. For instance, /xp add @s 30 levels adds 30 experience levels to yourself. Each example varies the arguments to show a different real use of /xp; read the note under every snippet to see exactly what changes.
/xp add @s 30 levelsAdds 30 experience levels to yourself.
/xp set @a 0 pointsResets the experience points (within current level) for all players to 0.
/xp query @p levelsQueries and displays the nearest player's current level.
Permission Level & Requirements
/xp sits at permission Level 2 - Game Master / Cheats, which means it needs permission level 2, the level cheats grant to single-player worlds and that operators hold by default.
In a single-player world you must have "Allow Cheats" turned on (or open the world to LAN with cheats) before it will run; on a multiplayer server the player needs to be an operator at the matching level.
This reference describes the Java Edition 1.21 form of the command; Bedrock Edition may use slightly different argument formats.
Common Mistakes
- Confusing points and levels, points fill the bar within a level, levels are the number shown on the bar.
- Using /xp set with points above the threshold for the current level, each level requires a different number of points.
Notes
The /xp command is functionally identical to /experience. Both are valid aliases in Java Edition.
Related Commands
If /xp is part of your toolkit, the commands below are the ones you will most often reach for alongside it: /experience and /enchant. They cover closely related tasks, so the links above jump straight to each one.
Frequently Asked Questions about /xp
What does the /xp command do in Minecraft?
Adds, sets, or queries experience points or levels for one or more players. This is an alias for /experience. It belongs to the player command group and was added in Java Edition 1.0.
What is the correct syntax for /xp?
/xp
What permission level does /xp need?
It requires permission Level 2 - Game Master / Cheats. On a server the player must be an operator at that level, or have cheats enabled in single-player.
What is a common mistake when using /xp?
Confusing points and levels, points fill the bar within a level, levels are the number shown on the bar.
Can you give an example of /xp in use?
Yes. /xp set @a 0 points — resets the experience points (within current level) for all players to 0.
Need a Minecraft server?
Try these commands on Astroworld or host your own server.
Try Astroworld Hosting