First, no matter which of the following methods is used, use a special fluid such as WD-40. It is a special fluid with excellent penetrating properties for loosening dirty and rusty fasteners. But it also works well on tight, broken fasteners. If enough of the bolt or stud is protruding from its hole and it is not too tight, it can often be loosened with pliers or a small pipe wrench. If this does not help, or the fasteners do not protrude enough to securely grip them with pliers or a key, try sawing it with a regular key or sawing a slot in it for a screwdriver.
If you still can't unscrew it, but know how to use welding, try welding a flat piece of steel or a nut onto the top of the broken fastener.
If a fastener is broken at or below the top of its hole, have it knocked out with a small, sharp punch.
If that doesn't help, try drilling out the broken fastener with a bit that is only slightly smaller than the inside diameter of the hole. For example, if the hole diameter is 12 mm, then use a drill with a diameter of 11 mm. This will leave a shell that can be knocked out with a sharp chisel. If this does not help, you need to resort to some kind of extractor. Extractors are sold in sets, they can unscrew bolts and studs with sizes of 6-25 mm.
Most extractors are conical, grooved and made of high quality steel. To use an extractor, drill a hole slightly smaller than the outside diameter of the extractor being used (extractor kits include manufacturer's recommendations on which drill size to use with each extractor size); then screw the extractor into the hole and remove it together with the broken screw or pin.
Thread extractors reverse (left), so they won't unscrew when you pull them out.
Tip: Extractors usually save effort and money, but if you are inattentive or in a hurry, it will even cause pain and damage. Drilling the hole for the extractor off-center, or using a bit that is too nice or too big for the bolt or stud to be removed, will only make things worse. Therefore, be careful!