Let K be a field and let UTn= UTn(K) denote the associative algebra of upper triangular n× n matrices over K. The vector space of UTn can be given the structure of a Lie and of a Jordan algebra, respectively, by means of the new products: [a, b] = ab- ba, and a∘ b= ab+ ba. We denote the corresponding Lie and Jordan algebra by UTn- and by UTn+, respectively. If G is a group, the G-gradings on UTn were described by Valenti and Zaicev (Arch Math 89(1):33–40, 2007); they proved that each grading on UTn is isomorphic to an elementary grading (that is every matrix unit is homogeneous). Also Di Vincenzo et al. (J Algebra 275(2):550–566, 2004) classified all elementary gradings on UTn. Here we study the gradings and the graded identities on UTn- and on UTn+, based on Koshlukov and Yukihide (J Algebra 473:66–79, 2017, J Algebra 477:294–311, 2017, Linear Algebra Appl, 2017). It turns out that the Lie and the Jordan cases are similar (though the methods used bear not much resemblance), and in turn, quite different from the associative case. We prove that, up to isomorphism, there are two kinds of gradings on UTn- and on UTn+: the elementary ones, and the so-called mirror type gradings. We classify all these gradings in the Lie and in the Jordan cases. Moreover we show that the gradings are completely determined by the graded identities they satisfy. © 2017, Instituto de Matemática e Estatística da Universidade de São Paulo.