Testing fundamental physics has become a major aim of modern cosmology, with the nature of gravity under very close scrutiny due to its plausible connection to cosmic acceleration. This program requires flexible tools to obtain accurate numerical predictions in a variety of models, which should also be fast to allow for an efficient exploration of their parameter spaces. We present the public version of the hi_class code (www.hiclass-code.net), an implementation into the Boltzmann code CLASS of very general modifications of gravity. hi_class can calculate predictions for models based on Horndeski's theory, which is the most general scalar-tensor theory described by second-order equations of motion and encompasses any perfect-fluid dark energy, quintessence, Brans-Dicke, f(R) and covariant Galileon models. The code internally uses a reformulation of the effective field theory for dark energy, based on the physical properties of the gravitational and scalar degrees of freedom. hi_class has been thoroughly tested and can be readily used to understand the impact of gravity on linear structure formation as well as for MCMC parameter extraction.