Defibrillators are a critical tool for treating heart disease; however, the mechanisms by which they halt fibrillation are still not fully understood and are the subject of ongoing research. Clinical defibrillators do not provide the precise control of shock timing, duration, and voltage or other features needed for detailed scientific inquiry, and there are few, if any, commercially available units designed for research applications. For this reason, we have developed a high-voltage, programmable, capacitive-discharge stimulator optimized to deliver defibrillation shocks with precise timing and voltage control to an isolated animal heart, either in air or in a bath. This stimulator is capable of delivering voltages of up to 500V and energies of nearly 100J with timing accuracy of a few microseconds and with rise and fall times of 5$\mu$s or less and is controlled only by two external timing pulses and a control computer that sets the stimulation parameters via a LABVIEW interface. Most importantly, the stimulator has circuits to protect the high-voltage circuitry and the operator from programming and input-output errors. This device has been tested and used successfully in field shock experiments on rabbit hearts as well as other protocols requiring high voltage.