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.
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?
+What is the difference between levels and points?
+How do I give XP to all players?
+How do I remove or reset a player's XP?
+Is /experience the same as /xp?
+Why does the /xp command not work?
/xp at a glance
Syntax
/xp <add|set|query> <targets> <amount>…Who may run it
What it does
Three things /xp is actually used for
/xp add @s 30 levels/xp set @s 0 levels/xp query @s levels/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
All 2 of these are named in the guide above, starting with Diamond. Look them up in the item database.