The phase mask is a diffractive optical element that is widely used for fabricating the fiber Bragg gratings (FBGs) for telecom and sensing applications. We analyze the near field diffraction of the phase mask with periodic phase-shift errors, e.g., stitching errors. Our analysis shows that the stitching errors generate sidelobe peaks beside the main diffraction orders of the phase mask. Experiments in the far-field diffraction prove the analysis results, so that we can estimate the e-beam writing field size by the far-field diffraction. We obtain the diffraction near field distribution using the Talbot formula, which explains, for the first time at our best knowledge, how the stitching errors are transferred into the FBG with the same periodicity during the side-writing process. We find out that the noise energy in the near field varies with the phase mask to fiber spacing. An optimal spacing can be found and used in order to reduce the stitching error related sidelobes in the FBG spectrum.