Updated:

1. Give the strongest spear

/give @s minecraft:netherite_spear[enchantments={sharpness:5,lunge:3,fire_aspect:2,looting:3,knockback:2,unbreaking:3,mending:1}]

Spears take the sword enchantments except Sweeping Edge, plus the spear-only Lunge.

2. Spear tiers

wooden_spear, stone_spear, copper_spear, iron_spear, golden_spear, diamond_spear and netherite_spear. Jab cooldown is shortest for wood and longest for netherite.

3. Jab and charge

Attack for a quick jab with knockback that can hit several mobs. Hold use to charge; damage depends on your speed, the target speed and your view angle, and a mounted charge can knock riders off.

4. How Lunge works

Lunge (max level 3) pushes you forward when you jab, farthest when you look level. Each use costs 1 durability and some hunger. It needs at least 6 hunger points and does not work in water or while gliding.

5. Over-max levels

/give @s minecraft:netherite_spear[enchantments={sharpness:255,unbreaking:255}]

See the enchantment ID list.

6. Mobs with spears

/summon minecraft:zombie ~ ~ ~ {equipment:{mainhand:{id:"minecraft:iron_spear",count:1}}}

Mob spears have half the reach but can dismount targets at lower speeds.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.