A numerical technique, based on the collocation method, for solving the diffusion equation is presented. The method is applicable to general problem of diffusion including the cases where the diffusion properties are inhomogeneous and time dependent. It is also applicable to the problem of nonlinear diffusion where the diffusion coefficient is dependent on the concentration of the diffusants. Examples to show the applicability and computational efficiency of the method have also been included.