It is intended to design compact heat exchangers which can transfer high heat flow for a given volume and temperature difference with high efficiency. This work presents the optimal design of heat exchangers for a given length or hydraulic diameter with a constraint of a certain pressure loss and constant wall temperature. Both volumetric heat transfer and heat transfer efficiency are taken into consideration for the design in laminar or turbulent flow regions. Equations are derived which easily enable optimal design for all shapes of ducts and for all Pr numbers. It is found that optimum conditions for turbulent flow is possible for all duct hydraulic diameters; however, it is possible to have optimum conditions till a certain dimensionless duct hydraulic diameter for laminar flow. Besides maximal volumetric heat flow, heat transfer efficiency should be taken into consideration in turbulent flow for optimum design.