We have developed an automated method for optimizing the design of a coil for magnetic stimulation of peripheral nerves, acting on the current distribution of the coil. The method consists of these steps: 1 generating a 3-D finite-element model of a coil laid on a forearm; 2 solving the model for two parameters,f1 and f2 of the activating function, which is responsible for the peripheral nerve stimulation; and 3 starting from an existing prototype, applying an evolutionary algorithm to maximize f1 and minimize f2 . The final aim is to obtain a focused and strong stimulation. In order to determine robust solutions, the method considers a sensitivity constraint and obtains two solutions, one without the sensitivity constraint and the other taking it into account. In both cases, the objective functions are improved with respect to the existing prototype. In conclusion, we discuss the structure of the objective space.