We present a unified ab initio study of electronic and optical properties of TiO 2 rutile and anatase phases with a combination of density-functional theory and many-body perturbation-theory techniques. The consistent treatment of exchange and correlation, with the inclusion of many-body one-particle and two-particles effects in self-energy and electron-hole interaction, produces a high-quality description of electronic and optical properties, giving, for some quantities, the first available estimation for this compound. In particular, we give a quantitative estimate of the electronic and direct optical gaps, clarifying their role with respect to previous measurements obtained by various experimental techniques. We obtain a description for both electronic gap and optical spectra that is consistent with experiments by analyzing the role of different contributions to the experimental optical gap and relating them to the level of theory used in our calculations. We also show the spatial properties of excitons in the two crystalline phases, highlighting the localization character of different optical transitions. This paper aims at understanding and firmly establishing electro-optical bulk properties, yet to be clarified, of this material of fundamental and technological interest for green energy applications.