Tensor hierarchy algebras constitute a class of non-contragredient Lie superalgebras, whose finite-dimensional members are the "Cartan-type" Lie superalgebras in Kac's classification. They have applications in mathematical physics, especially in extended geometry and gauged supergravity. We further develop the recently proposed definition of tensor hierarchy algebras in terms of generators and relations encoded in a Dynkin diagram (which coincides with the diagram for a related Borcherds superalgebra). We apply it to cases where a grey node is added to the Dynkin diagram of a rank r + 1 Kac-Moody algebra g + , which in turn is an extension of a rank r finite-dimensional semisimple simply laced Lie algebra g. The algebras are specified by g together with a dominant integral weight λ. As a by-product, a remarkable identity involving representation matrices for arbitrary integral highest weight representations of g is proven. An accompanying paper [ ] describes the application of tensor hierarchy algebras to the gauge structure and dynamics in models of extended geometry.