Due to the extremely high diffractive efficiency and flexible design freedom, binary optical element can realize specific function in the optical system in comparison with the traditional refractive optical element. Ptychography, which is a typical lensless optical imaging technology with simple structure, has the advantages of the extensible imaging range and high resolution. The topography of binary optical element can produce the phase difference between the illumination and transmission fields. The features of binary optical element are based on the complex amplitude modulation. So we can obtain the complex transmission function by using ptychography to realize the phase retrieval. In this paper, we propose a detection method for binary diffractive optical element based on ptychography. An improved ptychography optical system is designed by using the combination of variable aperture and lens to control the illumination field. Because the illumination field is a diverging spherical wave, the diffractive patterns can avoid the high contrast and the reconstruction result will contain more details of the sample. The proposed method can not only inspect a large region of the binary optical element, but also calibrate its feature size, such as step height. Compared with the traditional binary optical element detection methods, the proposed method can simplify the system structure, and it can be applied to special environment by using lensless imaging technology. The increasing of the diffraction pattern numbers can acquire the topography of the large size sample and improve the detection efficiency. Taking a phase step plate for sample, the simulations are conducted to analyze the influences of step height and noise on the recovery result. The results show that the detection range of step height is less than 1.5. We can realize a preferable sample reconstruction when the noise of diffraction pattern is less than 5%. A computer-generated holography (CGH) is reconstructed by using the extended ptychographic iterative engine. The diameter of illumination filed is selected to be about 2 mm in order to obtain a large detection region of the sample. The surface micro topography of CGH can be shown through the m 1.98 mm1.98 mm recovery result. More details can be obtained by changing the diameter of illumination filed about 1.6 mm. The recovery result is quite accurate and the error of step height is less than 30 nm compared with the result of white light interference detection. The simulation and experimental results verify the feasibility of this method. When the requirement for accuracy is not extremely high, the proposed method can obtain a satisfactory image quality. In addition, we hope to improve the proposed method, which can be more accurate to detect different types of optical elements in the future research.