Context. It has been established that the classical gas-phase production of interstellar methanol (CH 3 OH) cannot explain observed abundances. Instead it is now generally thought that the main formation path has to be by successive hydrogenation of solid CO on interstellar grain surfaces. Aims. While theoretical models and laboratory experiments show that methanol is efficiently formed from CO on cold grains, our aim is to test this scenario by astronomical observations of gas associated with young stellar objects (YSOs). Methods. We have observed the rotational transition quartets J = 2 K -1 K of 12 CH 3 OH and 13 CH 3 OH at 96.7 and 94.4 GHz, respectively, towards a sample of massive YSOs in different stages of evolution. In addition, the J = 1−0 transitions of 12 C 18 O and 13 C 18 O were observed towards some of these sources. We use the 12 C/ 13 C ratio to discriminate between gas-phase and grain surface origin: If methanol is formed from CO on grains, the ratios should be similar in CH 3 OH and CO. If not, the ratio should be higher in CH 3 OH due to 13 C fractionation in cold CO gas. We also estimate the abundance ratios between the nuclear spin types of methanol (E and A). If methanol is formed on grains, this ratio is likely to have been thermalized at the low physical temperature of the grain, and therefore show a relative over-abundance of A-methanol. Results. We show that the 12 C/ 13 C isotopic ratio is very similar in gas-phase CH 3 OH and C 18 O, on the spatial scale of about 40 , towards four YSOs. For two of our sources we find an overabundance of A-methanol as compared to E-methanol, corresponding to nuclear spin temperatures of 10 and 16 K. For the remaining five sources, the methanol E/A ratio is less than unity. Conclusions. While the 12 C/ 13 C ratio test is consistent with methanol formation from hydrogenation of CO on grain surfaces, the result of the E/A ratio test is inconclusive.