Undulatory swimming animals exhibit diverse ranges of body shapes and motion patterns and are often considered as having superior locomotory performance. The extent to which morphological traits of swimming animals have evolved owing to primarily locomotion considerations is, however, not clear. To shed some light on that question, we present here the optimal shape and motion of undulatory swimming organisms obtained by optimizing locomotive performance measures within the framework of a combined hydrodynamical, structural and novel muscular model. We develop a muscular model for periodic muscle contraction which provides relevant kinematic and energetic quantities required to describe swimming. Using an evolutionary algorithm, we performed a multi-objective optimization for achieving maximum sustained swimming speed U and minimum cost of transport (COT)-two conflicting locomotive performance measures that have been conjectured as likely to increase fitness for survival. Starting from an initial population of random characteristics, our results show that, for a range of size scales, fishlike body shapes and motion indeed emerge when U and COT are optimized. Inherent boundary-layerdependent allometric scaling between body mass and kinematic and energetic quantities of the optimal populations is observed. The trade-off between U and COT affects the geometry, kinematics and energetics of swimming organisms. Our results are corroborated by empirical data from swimming animals over nine orders of magnitude in size, supporting the notion that optimizing U and COT could be the driving force of evolution in many species.