Experience/Old Experience 2
The first 16 levels are linear (17 XP points per level), while level 17+ require more points per level compared to the prior level.
Note that when enchanting, the experience levels used will be subtracted from your current level, not your current XP total. This has important implications for leveling above 30—the levels gained will have a high XP cost, but this will not be preserved. For example, if you are enchanting anything at level 30: if you earn enough experience to get to level 31, then enchant, you will be left at level 1. If you had enchanted first, and collected the same amount of experience afterwards, you would have almost reached level 4. Because of this, there is no useful purpose to earning experience past level 39, as this is the maximum level an anvil will require before an item is "too expensive" to enchant or repair.
Formulas & tables[edit]
The experience cost for gaining a level is equivalent to:
int expCost(int currentLevel) { if (currentLevel >= 30) { return 62 + (currentLevel  30) * 7; } else if (currentLevel >= 15) { return 17 + (currentLevel  15) * 3; } else { return 17; } }
This works out as follows:
 If your current level is 14 or below, you need a static 17 experience to gain the next level.
 For current levels from 15 to 29, each level takes 3 more experience, amounting to (17 + (currentLevel  15) * 3) experience to gain another level.
 At and above level 30, each new level takes 7 more experience, totaling (62 + (currentLevel  30) * 7).
The total XP required for a given level (x) can be calculated as follows:
 for x<15: 17x
 for 16≤x<30: 1.5x²  29.5x + 360
 for x≥30: 3.5x²  151.5x + 2220
Level  Exp  Exp from last 

1  17  17 
2  34  17 
3  51  17 
4  68  17 
5  85  17 
6  102  17 
7  119  17 
8  136  17 
9  153  17 
10  170  17 
Level  Exp  Exp from last 

11  187  17 
12  204  17 
13  221  17 
14  238  17 
15  255  17 
16  272  17 
17  292  20 
18  315  23 
19  341  26 
20  370  29 
Level  Exp  Exp from last 

21  402  32 
22  437  35 
23  475  38 
24  516  41 
25  560  44 
26  607  47 
27  657  50 
28  710  53 
29  766  56 
30  825  59 
Level  Exp  Exp from last 

31  887  62 
32  956  69 
33  1032  76 
34  1115  83 
35  1205  90 
36  1302  97 
37  1406  104 
38  1517  111 
39  1635  118 
40  1760  125 
Useful numbers[edit]
 Killing one large slime and all the slimes that split from it will yield from 12 to 28 experience, with an average of 19.
 The maximum that can be used on a single enchantment is 30 levels, while the anvil will accept jobs up to level 39 (in creative mode the anvil limit is lifted).
 Level 16 is a third of the way to level 30, while level 22 is about halfway there. Level 30 in turn, is halfway to level 39.
 One can determine how much experience has been collected to reach a level using the equations:

 Total Experience = 17[Level] (at levels 015)




 1.5[Level]^{2}  29.5[Level] + 360 (at levels 1630)
 3.5[Level]^{2}  151.5[Level] + 2220 (at level 31+)




 Total Experience = 17[Level] (at levels 015)
 This equation does not include any experience that is currently filling the experience bar.
 Additionally, the amount of experience required to advance to the next level can be calculated using the equations:
 Experience Required = 17 (at levels 014)





 3[Current Level] 28 (at levels 1529)
 7[Current Level]  148 (at level 30+)





 Experience Required = 17 (at levels 014)
 Killing the Ender Dragon will give approximately 78 XP levels. The Ender Dragon actually drops 10 orbs worth 1,000 experience points, and another worth 2,000. Taken separately, the smaller orbs could take a player from zero to level 32, while the big orb would take a player from zero to level 41.
 Maximum xp value can be gained by /xp command is 2147483647 (which is 2^31  1. Likely a limitation due to the 32 bit nature of Minecraft.)
 Maximum level is 24791