In this paper we describe a general framework for deriving modified equations for stochastic differential equations (SDEs) with respect to weak convergence. Modified equations are derived for a variety of numerical methods, such as the Euler or the Milstein method. Existence of higher order modified equations is also discussed. In the case of linear SDEs, using the Gaussianity of the underlying solutions, we derive a SDE which the numerical method solves exactly in the weak sense. Applications of modified equations in the numerical study of Langevin equations is also discussed