The habitability of planets orbiting M dwarfs may be compromised by the host star’s XUV flux that results from flares, which can increase the quiescent XUV flux by up to 2 orders of magnitude. This wavelength range warms and ionizes Earth-like planets’ upper atmospheres, expanding this layer and driving atmospheric loss. The main goal of the present work is to quantify the contribution of the XUV flux due flares in the atmospheric escape of Earth-like planets in the habitable zones of M dwarfs. We therefore developed a new module for VPLanet called FLARE that simulates stellar flares for stellar masses between 0.2 and 0.6 solar masses. We simulate planets with masses between 0.5 and 5 masses of Earth, and with a initial surface water abundances between 1 and 10 times modern Earth’s ocean abundance. We find that flaring can remove up to 4 additional Earth oceans, significantly reducing these planets likelihood to support habitable conditions. We also find that flares increases oxygen accumulation in the atmospheres by up to 800 bars. For those planets that also retain surface water, this excess oxygen could also create a protective ozone layer against the biological damage caused by the enhanced XUV radiation from flares.