This paper presents a numerical investigation of the entropy generation and heat transfer in a ferrofluid (water and 4% Fe 3 O 4 nanoparticles) filled cavity with natural convection using a two phase mixture model and control volume technique. The effect of applying a nonuniform magnetic field on the entropy generation and heat transfer in the cavity and also the interaction of magnetic force and the buoyancy force are investigated. Based on the obtained results, applying a magnetic field will enhance the heat transfer mechanism. Furthermore, by applying the nonuniform magnetic field on the ferrofluid filled cavity with natural convection, the total entropy generation is decreased considerably at higher Rayleigh numbers. Therefore, applying a magnetic field can be considered as a suitable method for entropy generation minimization in order to have high efficiency in the system. C⃝ 2016 Wiley Periodicals, Inc. Heat Trans Asian Res, 00(0): 1-25, 2016; Published online in Wiley Online Library (wileyonlinelibrary.com/journal/htj).