Context : Aims : We study the H _ { 2 } O chemistry in star-forming environments under the influence of a central X-ray source and a central far ultraviolet ( FUV ) radiation field . The X-ray models are applied to envelopes around low-mass Class 0 and I young stellar objects ( YSOs ) . Methods : The gas-phase water chemistry is modeled as a function of time , hydrogen density and X-ray flux . To cover a wide range of physical environments , densities between n _ { H } = 10 ^ { 4 } – 10 ^ { 9 } cm ^ { -3 } and temperatures between T = 10 – 1000 K are studied . Results : Three different regimes are found : For T < 100 K , the water abundance is of order 10 ^ { -7 } – 10 ^ { -6 } and can be somewhat enhanced or reduced due to X-rays , depending on time and density . For 100 K \lesssim T \lesssim 250 K , H _ { 2 } O is reduced from initial x ( { H _ { 2 } O } ) \approx 10 ^ { -4 } following ice evaporation to x ( { H _ { 2 } O } ) \approx 10 ^ { -6 } for F _ { X } \gtrsim 10 ^ { -3 } ergs s ^ { -1 } cm ^ { -2 } ( t = 10 ^ { 4 } yrs ) and for F _ { X } \gtrsim 10 ^ { -4 } ergs s ^ { -1 } cm ^ { -2 } ( t = 10 ^ { 5 } yrs ) . At higher temperatures ( T \gtrsim 250 K ) and hydrogen densities , water can persist with x ( { H _ { 2 } O } ) \approx 10 ^ { -4 } even for high X-ray fluxes . Water is destroyed in both Class 0 and I envelopes on relatively short timescales ( t \approx 5000 yrs ) for realistic X-ray fluxes , although the effect is less prominent in Class 0 envelopes due to the higher X-ray absorbing densities there . FUV photons from the central source are not effective in destroying water . Conclusions : X-rays reduce the water abundances especially in regions where the gas temperature is T \lesssim 250 – 300 K for fluxes F _ { X } \gtrsim 10 ^ { -5 } – 10 ^ { -4 } ergs s ^ { -1 } cm ^ { -2 } . The affected regions can be envelopes , disks or outflow hot spots . The average water abundance in Class I sources for L _ { X } \gtrsim 10 ^ { 27 } ergs s ^ { -1 } is predicted to be x ( { H _ { 2 } O } ) \lesssim 10 ^ { -6 } . Central UV fields have a negligible influence , unless the photons can escape through cavities .