Sword

A sword is a melee weapon that is mainly used to deal damage to mobs and/or players. Swords are also useful for mining cobwebs.

Unit repair
A sword can be repaired in an anvil by adding units of the tiers' repair material, with each repair material restoring 25% the sword's maximum durability, rounded down.

Mobs
Some monsters can spawn with a sword and have an 8.5% chance of dropping them upon death by player. This chance is increased by 1% per level of Looting, up to a maximum of 11.5% with Looting III. Zombies and husks can drop iron swords, zombie pigmen and piglins can drop golden swords, and wither skeletons can drop stone swords. The dropped sword is usually badly damaged and may be enchanted. Stone swords dropped by wither skeletons are never enchanted.

A vex wields an iron sword that normally has a 0% chance of dropping, because their main hand's  is 0. However, this chance increases by 1 percentage point per level of Looting. It is never damaged and may be enchanted.

In Bedrock Edition, pillagers and vindicators that spawn from raids have a 4.1% chance (5.12% chance on hard) of dropping an iron sword, badly damaged although it can be enchanted with a random enchantment.

Trading
Apprentice-level weaponsmith villagers sell enchanted iron swords for 2 emeralds, and expert-level weaponsmiths sell enchanted diamond swords for 8 emeralds.

Novice-level weaponsmith villagers have a $2/3$ chance of selling an enchanted iron sword for 7-22 emeralds. Master-level weaponsmiths offer to sell an enchanted diamond sword for 11-27 emeralds.

The enchantments are the same as the ones obtained from an enchantment table at levels 5–19.

Natural generation

 * Notes

Attacking
Pressing while holding a sword inflicts damage on both mobs and other players. Upon damaging a mob or player, the sword's durability decreases by 1.

Attacking a boat or a minecart with a sword instantly destroys it, without decreasing the sword's durability.

Sweep attack
If the attack recharge meter is 84.8% or above, and the player is standing or moving no faster than walking speed, the sword performs a "sweep" attack that can hit nearby enemies. Enemies near the hit enemy are knocked back and damaged by from the slashing attack. The Sweeping Edge enchantment increases the damage dealt by 50% of the normal hit damage for level I, 67% for level II, and 75% for level III. The amount of knockback is 80% that of the knockback due to Knockback I (in other words, 2.8 blocks), and does not benefit from that enchantment. All enemies within 1 block horizontally and 0.25 blocks vertically of any part of the attacked mob and within up to 4 blocks of the player are knocked back. It is impossible to perform both a sweep attack and critical hit on the same attack. A sweeping attack is performed only when the player swings downward; hitting an entity above the player's head does not perform a sweep attack.

Java Edition
Swords have an attack speed of 1.6 and take 0.625 seconds to recover.

Bedrock Edition
$$, swords have no attack cooldown or sweep attack and do the following damage:

The most amount of damage that a diamond sword enchanted with Sharpness V can do is 10 $$ and 14.5 $$, without critical hits.

Knockback
$$, the knockback inflicted by swords is a bit higher than other melee items, especially while sprinting.

Sword breaking times
A sword can also be used to destroy certain blocks more quickly than with fists. Using a sword to destroy any block that doesn't break instantly decreases its durability by 2.

If a sword is enchanted with Silk Touch, either using Creative or commands, it can collect cobwebs rather than getting the string drop. This is due to the sword being classified as the proper tool for cobwebs.

The following table shows the time it takes to break blocks on which swords have any effect. Colors indicate what gets dropped:
 * White: an original block.
 * Blue: block's normal drop (e.g. seeds, sapling, apple).
 * Red: nothing.

Swords can also be used for instant breaking of bamboo.

Safety around constructions
In Creative mode, swords are unable to break most blocks. However, they can "break" (put out) fire, which are considered blocks. Care must also be taken around minecarts, paintings, item frames and armor stands, which are also not safe with swords in Creative.

Enchantments
Swords can receive the following enchantments:

Fuel
Wooden swords can be used as a fuel in furnaces, smelting 1 item per sword.

Video
''Note: This video is outdated. Since Java Edition 1.9, swords can no longer block attacks. Instead, shields are used.''

History
"The sword has been a part of Minecraft since January 2010, when it was added alongside diamonds, sticks... oh, and the entire crafting system. Since then, the basic sword concept has pretty much stayed the same but the details have been tweaked repeatedly. Enchantments were added in version 1.0.0, drops from mobs in 1.2.1, and 1.9 – the combat update – changed things up all over again."

- Duncan Geere

Trivia

 * The sword's texture came from Notch's abandoned RPG, Legend of the Chambered. The iron sword's texture was created first, as it was from the game, and the other swords followed.
 * With the introduction of netherite swords, it is possible to one-hit kill all undead mobs in the game (except withers and zombies/skeletons with random armor) using a sword with the Smite V enchantment, without the need to perform a critical hit (this was previously only possible with a Smite V stone, iron, or diamond ax). This may make the Smite enchantment more desirable.