What is the max enchantment level using commands?
Solution 1:
1.13+ players, please see the other answer.
1.12−
Enchantment levels are saved as a Short, with a minimum of -32,768 and maximum of 32,767.
/give @p minecraft:stone 1 0 {ench:[{id:16s,lvl:32767s}]}
You can find further information on the NBT format here.
Solution 2:
Maximum displayable enchantment level
This answer shows the maximum enchantment level that can be displayed on the item tooltip. See this answer for the maximum effective enchantment levels.
1.17+ Update
From the Minecraft Wiki:
lvl: The level of the enchantment, where 1 is level 1. Values are clamped between 0 and 255 when reading.
This means that the maximum enchantment level is 255. Affix an s
to the end of the number to mark it as a Short tag, to take up the least memory.
1.13+ Update
From the Minecraft Wiki:
lvl: The level of the enchantment, where 1 is level 1. Saved as short when created by enchanting tables or loot tables, but read as an int and supports full int range.
In layman's terms, the Survival means like loot tables, anvils, and enchanting tables save the number as a Short, but when they are actually applied to items, they are read as an Integer.
Therefore, you don't need to stick to the Short data type just because that is what the enchantment tables use. You are allowed to use the Integer data type because that is how the enchantment levels are read.
The maximum integer is 2,147,483,647.
/give @s netherite_sword{Enchantments:[{id:"minecraft:sharpness",lvl:2147483647}]}