Context. Long Gamma-Ray Bursts (GRBs) offer a promising tool to trace the cosmic history of star formation, especially at high redshift where conventional methods are known to suffer from intrinsic biases. Previous studies of GRB host galaxies at low redshift showed that high surface densities of stellar mass and star formation rate (SFR) can potentially enhance the GRB production. Evaluating the effect of such stellar densities at high redshift is therefore crucial to fully control the ability of long GRBs for probing the activity of star formation in the distant Universe. Aims. We assess how the size, the stellar mass and star formation rate surface densities of distant galaxies affect their probability to host a long GRB, using a sample of GRB hosts at z > 1 and a control sample of star-forming sources from the field. Methods. We gather a sample of 45 GRB host galaxies at 1 < z < 3.1 observed with the Hubble Space Telescope WFC3 camera in the near-infrared. Our subsample at 1 < z < 2 has cumulative distributions of redshift and stellar mass consistent with the host galaxies of already-known unbiased GRB samples, while our GRB host selection at 2 < z < 3.1 has lower statistics and is probably biased to the high end of the stellar mass function. Using the GALFIT parametric approach, we model the GRB host light profile with a Sérsic component and derive the half-light radius for 35 GRB hosts, which we use to estimate the star formation rate and stellar mass surface densities of each object. We compare the distribution of these physical quantities to the SFR-weighted properties of a complete sample of star-forming galaxies from the 3D-HST deep survey at comparable redshift and stellar mass. Results. We show that, similarly to z < 1, GRB hosts are smaller in size and they have higher stellar mass and star formation rate surface densities than field galaxies at 1 < z < 2. Interestingly, this result is robust even when considering separately the hosts of GRBs with optically-bright afterglows and the hosts of dark GRBs, as the two subsamples share similar size distributions. At z > 2 though, GRB hosts appear to have sizes and stellar mass surface densities more consistent with those characterizing the field galaxies. This may reveal an evolution with redshift of the bias between GRB hosts and the overall population of star-forming sources, although we cannot exclude that our result at z > 2 is also affected by the prevalence of dark GRBs in our selection. Conclusions. In addition to a possible trend toward low metallicity environment, other environmental properties such as stellar density appears to play a role in the formation of long GRBs, at least up to z ∼ 2. This might suggest that GRBs require special environments to be produced.