In this talk I will present recent results showing how the high-temperature phase of the compact U(1) gauge theory (without matter fields) in 2+1 spacetime dimensions can be studied in terms of the conformal-field-theory predictions for the low-temperature phase of the XY model in 2 dimensions. The conformally-invariant analytical description of the XY model is compared with numerical results obtained in lattice simulations of the U(1) gauge theory, in particular for the two-point correlation function of static charges and for the flux-tube profile: excellent agreement is found when testing the functional forms and when computing the critical indices predicted by conformal field theory.