Abstract : This paper describes an efficient algorithm for computing steady two-dimensional surface gravity wave in irrotational motion. The algorithm complexity is O(N log N), N being the number of Fourier modes. The algorithm allows the arbitrary precision computation of waves in arbitrary depth, i.e., it works efficiently for Stokes, cnoidal and solitary waves, even for quite large steepnesses. The method is based on conformal mapping, Babenko equation rewritten in a suitable way, pseudo-spectral method and Petviashvili's iterations. The efficiency of the algorithm is illustrated via some relevant numerical examples. The code is open source, so interested readers can easily check the claims, use and modify the algorithm.