We develop a method for computing a nearly singular integral, such as a double layer potential due to sources on a curve in the plane, evaluated at a point near the curve. The approach is to regularize the singularity and obtain a preliminary value from a standard quadrature rule. Then we add corrections for the errors due to smoothing and discretization, which are found by asymptotic analysis. We prove an error estimate for the corrected value, uniform with respect to the point of evaluation. One application is a simple method for solving the Dirichlet problem for Laplace's equation on a grid covering an irregular region in the plane, similar to an earlier method of A. Mayo [SIAM J. Sci. Statist. Comput., 6 (1985), pp. 144-157]. This approach could also be used to compute the pressure gradient due to a force on a moving boundary in an incompressible fluid. Computational examples are given for the double layer potential and for the Dirichlet problem.