The diamond sword is the fifth weapon purchasable from the candy merchant in Candy Box. It can be bought with 2000 candies. When you add 101 candies to this weapon, you get the upgrade: candy diamond sword.
You can then choose to crush 30 lollipops into a powder to coat the sword, creating the Polished Diamond Sword.
After obtaining the chocolate bar from The Frog of Swampy Swamp, you can coat the sword in chocolate, creating the Chocolate Sword.