Most back hole and neutron star progenitors are found in triples or higher multiplicity systems. Here, we present a new triple stellar evolution code, TSE, which simultaneously takes into account the physics of the stars and their gravitational interaction. TSE is used to simulate the evolution of massive stellar triples in the galactic field from the zero-age-main-sequence until they form compact objects. To this end, we implement initial conditions that incorporate the observed high correlation between the orbital parameters of early-type stars. We show that the interaction with a tertiary companion can significantly impact the evolution of the inner binary. High eccentricities can be induced by the third-body dynamical effects, leading to a Roche lobe overflow or even to a stellar merger from initial binary separations 10 3 -10 5 R . In ∼ 5 % of the systems the tertiary companion itself fills its Roche lobe, while ∼ 10 % of all systems become dynamically unstable. We find that between 0.3% and 5% of systems form a stable triple with an inner compact object binary, where the exact fraction depends on metallicity and the natal kick prescription. The vast majority of these triples are binary black holes with black hole companions. We find no binary neutron star in any surviving triple, unless zero natal kicks are assumed. About half of all black hole binaries formed in our models are in triples, where in the majority the tertiary black hole is able to perturb their long-term evolution. Our results show that triple interactions are key to a full understanding of massive star evolution and compact object binary formation.