A program has been developed that automatically optimizes internal defibrillation electrode shape, size and position with respect to the heart according to a number of useful criteria, such as electric field uniformity, current density and power density. The program design, some preliminary numerical experiments and their results are presented.