Context. Water is a key molecule in star- and planet-forming regions. Recent water line observations toward several low-mass protostars suggest low water gas fractional abundances (<10−6 with respect to total hydrogen density) in the inner warm envelopes (r < 102 au). Water destruction by X-rays is thought to influence the water abundances in these regions, but the detailed chemistry, including the nature of alternative oxygen carriers, is not yet understood. Aims. Our aim is to understand the impact of X-rays on the composition of low-mass protostellar envelopes, focusing specifically on water and related oxygen-bearing species. Methods. We computed the chemical composition of two proto-typical low-mass protostellar envelopes using a 1D gas-grain chemical reaction network. We varied the X-ray luminosities of the central protostars, and thus the X-ray ionization rates in the protostellar envelopes. Results. The protostellar X-ray luminosity has a strong effect on the water gas abundances, both within and outside the H2O snowline (Tgas ~ 102 K, r ~ 102 au). Outside, the water gas abundance increases with LX, from ~10−10 for low LX to ~10−8–10−7 at LX > 1030 erg s−1. Inside, water maintains a high abundance of ~10−4 for LX ≲ 1029–1030 erg s−1, with water and CO being the dominant oxygen carriers. For LX ≳ 1030–1031 erg s−1, the water gas abundances significantly decrease just inside the water snowline (down to ~10−8–10−7) and in the innermost regions with Tgas ≳ 250 K (~10−6). For these cases, the fractional abundances of O2 and O gas reach ~10−4 within the water snowline, and they become the dominant oxygen carriers. In addition, the fractional abundances of HCO+ and CH3OH, which have been used as tracers of the water snowline, significantly increase and decrease, respectively, within the water snowline as the X-ray fluxes become larger. The fractional abundances of some other dominant molecules, such as CO2, OH, CH4, HCN, and NH3, are also affected by strong X-ray fields, especially within their own snowlines. These X-ray effects are larger in lower-density envelope models. Conclusions. X-ray-induced chemistry strongly affects the abundances of water and related molecules including O, O2, HCO+, and CH3OH, and can explain the observed low water gas abundances in the inner protostellar envelopes. In the presence of strong X-ray fields, gas-phase water molecules within the water snowline are mainly destroyed with ion-molecule reactions and X-ray-induced photodissociation. Future observations of water and related molecules (using, e.g., ALMA and ngVLA) will access the regions around protostars where such X-ray-induced chemistry is effective.