In this paper the dependence of the best constants in Sobolev and Gagliardo–Nirenberg inequalities on the precise form of the Sobolev space norm is investigated. The analysis is carried out on general graded Lie groups, thus including the cases of mathbb {R}^n, Heisenberg, and general stratified Lie groups, in all these cases the results being new. The Sobolev norms may be defined in terms of Rockland operators, i.e. the hypoelliptic homogeneous left-invariant differential operators on the group. The best constants are expressed in the variational form as well as in terms of the ground state solutions of the corresponding nonlinear subelliptic equations. The orders of these equations can be high depending on the Sobolev space order in the Sobolev or Gagliardo–Nirenberg inequalities, or may be fractional. Applications are obtained also to equations with lower order terms given by different hypoelliptic operators. Already in the case of {mathbb {R}}^n, the obtained results extend the classical relations by Weinstein (Commun Math Phys 87(4):567–576 (1982/1983)) to a wide range of nonlinear elliptic equations of high orders with elliptic low order terms and a wide range of interpolation inequalities of Gagliardo–Nirenberg type. However, the proofs are different from those in Weinstein (Commun Math Phys 87(4):567–576 (1982/1983)) because of the impossibility of using the rearrangement inequalities already in the setting of the Heisenberg group. The considered class of graded groups is the most general class of nilpotent Lie groups where one can still consider hypoelliptic homogeneous invariant differential operators and the corresponding subelliptic differential equations.