hero-image

How to give XP in Minecraft using commands

XP in Minecraft is a vital resource, required for tasks including enchanting and using the anvil to repair, rename, and merge enchantments for items and gear. For this reason, having as many XP levels as possible is always a good thing. While you can collect XP using structures like mob farms, it's also possible to give yourself or other players experience points and levels by using commands.

With cheats enabled on a world or server, you can use the /experience or /xp commands to provide experience points to a player or add XP levels. It's also possible to set the number of XP levels a player currently has.

Whatever the case, if you need some XP in a pinch, it's worth taking a look at how to provide it with commands in Minecraft.


How to give yourself or others XP in Minecraft using commands

The experience commands in Minecraft are quite simple to use (Image via Mojang)
The experience commands in Minecraft are quite simple to use (Image via Mojang)

Before using the /xp or /experience commands in Minecraft, you'll need to enable cheats on your world or server or at least have operator/admin privileges on a given server. Otherwise, any commands entered in the chat console won't execute. The same goes for command blocks, which can't be obtained under ordinary circumstances in the vanilla game without commands regardless.

At any rate, the base structure of the two experience commands as of Minecraft 1.21 is as follows:

  • To Add Experience to a Player - /experience add <targets> <amount> [levels|points] or /xp add <targets> <amount> [levels|points]
  • To Set the Experience of a Player - /experience set <targets> <amount> [levels|points] or /xp set <targets> <amount> [levels|points]

From here, there's still some work to do. Specifically, you'll need to designate targets to add or set experience points/levels for and also determine an amount of experience points or levels. This is where the target selectors come in, which are marked with an @ and can be used to choose which players/entities a command will effect.

The full list of selectors can be found below:

  • @p: Selects the nearest player from the command execution.
  • @n (Java Edition only): Selects the nearest entity from the command execution.
  • @r: Selects a random player.
  • @a: Selects all players
  • @e: Selects all living entities in loading chunks.
  • @s: Selects the entity that executed the command, alive or not.
  • @c (Education Editon only): Selects the player's agent mob.
  • @v (Education Editon only): Selects all agent mobs.
  • @initiator (Bedrock Edition only): Selects the player who is interacting with a button while interacting with an NPC dialogue.

From here, all that's required is to choose how much experience you'd like to give a player in your Minecraft world/server.

With that in mind, you can enable cheats, open your chat window in-game, and enter commands, like the examples below, to provide experience to players:

  • Give 50,000 XP to yourself: /xp add @s 50000 or /experience add @s 50000
  • Give 50,000 XP to the nearest player: /xp @p add 50000 or /experience add @p 50000
  • Give 50,000 XP to all players: /xp add @a 50000 or /experience add @a 50000
  • Set the XP of yourself to 100,000: /xp set @s 100000 or /experience set @s 100000
  • Set the XP of the nearest player to 100,000: /xp set @p 100000 or /experience set @p 100000
  • Set XP for all players to 100,000: /xp set @a 100000 or /experience set @a 100000
You can add additional descriptions to this Minecraft command for fine-tuned control (Image via Mojang)
You can add additional descriptions to this Minecraft command for fine-tuned control (Image via Mojang)

As a final note, when using this Minecraft command, you can add levels or points at the end of the command to choose whether you'd prefer to gain pure experience points or levels.

Moreover, you can replace the target selector with a player's username (including your own) to select a target. Ultimately, the final decision is up to you.

You may also like