The invention relates to an environmentally friendly preparation method for vitamin B6. The method comprises the following steps: carrying out a condensation reaction on a carbonyl compound and 2-cyano-2-cis-butene-1,4-diol which is used as a starting material, protecting hydroxyl groups to obtain 2,2-disubstituted-5-cyano-4,7-dihydro-1,3-dioxepine, carrying out a formylation reaction on the 2,2-disubstituted-5-cyano-4,7-dihydro-1,3-dioxepine, carbon monoxide and hydrogen to prepare 2,2-disubstituted-5-cyano-6-formyl-1,3-dioxetpin, condensing the 2,2-disubstituted-5-cyano-6-formyl-1,3-dioxetpin and 2-aminopropionate or its hydrochloride, and removing the carbonyl compound to prepare the vitamin B6. The method does not use a 4-methyl-5-alkoxyoxazole intermediate which is expensive and generates a large amount of wastewater in the production process, so the method has the advantages of environmentally friendly process, high reaction selectivity, high product purity, high atom economy, and suitableness for industrial production.