We present the most extensive and complete study of the properties for the largest sample (46 objects) of gamma-ray burst (GRB) host galaxies. The redshift interval and the mean redshift of the sample are 0<z<6.3 and z=0.96 (look-back time: 7.2 Gyr), respectively; 89% of the hosts are at z <~ 1.6. Optical-near-infrared (NIR) photometry and spectroscopy are used to derive stellar masses, star formation rates (SFRs), dust extinctions and metallicities. The average stellar mass is 10^9.3 M_sun, with a 1 sigma dispersion of 0.8 dex. The average metallicity for a subsample of 17 hosts is about 1/6 solar and the dust extinction in the visual band (for a subsample of 10 hosts) is A_V=0.5. We obtain new relations to derive SFR from [OII] or UV fluxes, when Balmer emission lines are not available. SFRs, corrected for dust extinction, aperture-slit loss and stellar Balmer absorption are in the range 0.01-36 M_sun yr^-1. The median SFR per unit stellar mass (specific SFR) is 0.8 Gyr^-1. Equivalently the inverse quantity, the median formation timescale is 1.3 Gyr. Most GRBs are associated with the death of young massive stars, more common in star-forming galaxies. Therefore GRBs are an effective tool to detect star-forming galaxies in the universe. Star-forming galaxies at z<1.6 are a faint and low-mass population, hard to detect by conventional optical-NIR surveys, unless a GRB event occurs. There is no compelling evidence that GRB hosts are peculiar galaxies. More data on the subclass of short GRB are necessary to establish the nature of their hosts.