We reveal the existence of a certain hidden symmetry in general ghost-free scalar-tensor theories which can only be seen when generalizing the geometry of the spacetime from Riemannian. For this purpose, we study scalar-tensor theories in the metric-affine (Palatini) formalism of gravity, which we call scalar-metric-affine theories for short, where the metric and the connection are independent. We show that the projective symmetry, a local symmetry under a shift of the connection, can provide a ghost-free structure of scalar-metric-affine theories. The ghostly sector of the secondorder derivative of the scalar is absorbed into the projective gauge mode when the unitary gauge can be imposed. Incidentally, the connection does not have the kinetic term in these theories and then it is just an auxiliary field. We can thus (at least in principle) integrate the connection out and obtain a form of scalar-tensor theories in the Riemannian geometry. The projective symmetry then hides in the ghost-free scalar-tensor theories. As an explicit example, we show the relationship between the quadratic order scalar-metric-affine theory and the quadratic U-degenerate theory. The explicit correspondence between the metric-affine (Palatini) formalism and the metric one could be also useful for analyzing phenomenology such as inflation.1 In the paper [16], U-degenerate theories and DHOST theories are classified: U-degenerate theories are not degenerate in an arbitrary gauge but degenerate in the unitary gauge while DHOST theories are degenerate under any gauge. However, in the present paper, we will just call theories "U-degenerate theories" if the Lagrangian is degenerate at least in the unitary gauge for simplicity.