We investigate Hartman functions on a topological group G. Recall that (ι,C) is a group compactification of G if C is a compact group, ι: G → C is a continuous group homomorphism and ι(G) ⊆ C is dense. A bounded function f: G → ℂ is a Hartman function if there exists a group compactification (ι,C) and F: C → ℂ such that f = F∘ι and F is Riemann integrable, i.e. the set of discontinuities of F is a null set with respect to the Haar measure. In particular, we determine how large a compactification for a given group G and a Hartman function f: G → ℂ must be to admit a Riemann integrable representation of f. The connection to (weakly) almost periodic functions is investigated. In order to give a systematic presentation which is self-contained to a reasonable extent, we include several separate sections on the underlying concepts such as finitely additive measures on Boolean set algebras, means on algebras of functions, integration on compact spaces, compactifications of groups and semigroups, the Riemann integral on abstract spaces, invariance of measures and means, continuous extensions of transformations and operations to compactifications, etc.