/
!A screenshot from in game
/datapack folder of your world-save %appdata%/.minecraft/savesC:\Users\[USERNAME]\AppData\Roaming\.minecraft\saves\[WORLDNAME]\datapacks/reload in game/reload in game/trigger DurabilityHud.resourcepack/trigger DurabilityHud.resourcepack/trigger DurabilityHud.toggle/trigger DurabilityHud.armor
!In game screenshot of the commands in this packAs long as a item has the component max_damage it should display correctly. But as of 1.21.3 plain items from minecraft (and plain modded ones) dont come with the max_damage component by default. Therefore we hardcode these values, but as long as max_damage exists you should be fine.
If adding max_damage is not a option then it is possible to modify/override the get.max.[Slot].default.mcfunction to return custom max damage values for custom item types. Or add custom items to the existing durability.max.[maxdurability].json tag files under tags/item/....
items that are unable to get max damage will display negative values.

Displays durability of Tools, Weapons, and Armor.