We have developed the open-source software Tesseroids, a set of command-line programs to perform forward modeling of gravitational fields in spherical coordinates. The software is implemented in the C programming language and uses tesseroids (spherical prisms) for the discretization of the subsurface mass distribution. The gravitational fields of tesseroids are calculated numerically using the Gauss-Legendre quadrature (GLQ). We have improved upon an adaptive discretization algorithm to guarantee the accuracy of the GLQ integration. Our implementation of adaptive discretization uses a “stack-based” algorithm instead of recursion to achieve more control over execution errors and corner cases. The algorithm is controlled by a scalar value called the distance-size ratio () that determines the accuracy of the integration as well as the computation time. We have determined optimal values of for the gravitational potential, gravitational acceleration, and gravity gradient tensor by comparing the computed tesseroids effects with those of a homogenous spherical shell. The values required for a maximum relative error of 0.1% of the shell effects are for the gravitational potential, for the gravitational acceleration, and for the gravity gradients. Contrary to previous assumptions, our results show that the potential and its first and second derivatives require different values of to achieve the same accuracy. These values were incorporated as defaults in the software.