We show that the winding of the branches in a uniform spanning tree on a planar graph converge in the limit of fine mesh size to a Gaussian free field. The result holds assuming only convergence of simple random walk to Brownian motion and a Russo.Seymour.Welsh type crossing estimate, thereby establishing a strong form of universality. As an application, we prove universality of the fluctuations of the height function associated to the dimer model, in several situations. The proof relies on a connection to imaginary geometry, where the scaling limit of a uniform spanning tree is viewed as a set of flow lines associated to a Gaussian free field. In particular, we obtain an explicit construction of the a.s. unique Gaussian free field coupled to a continuum uniform spanning tree in this way, which is of independent interest.