This paper reports the effect of thickness and grain size on the coercivity of Ni81Fe19 permalloy thin films (2.5-30 nm) sputtered on glass substrates for their application in magnetoresistive sensors. Coercivity was systematically investigated as a function of underlayer materials, thickness, and substrate temperature. Lateral grain size of the sputtered films was investigated. The grain size reduced very quickly in the thinner films. It was also found that the coercivity of the films with very small lateral grain size is much lower than those with a normal grain size. The lowest coercivity (Hc=0.8 Oe) was observed in 7.5 nm thick film and having a grain size of 4 nm. When an underlayer is used, its crystallinity affects the lateral grain size in the permalloy and correlates with the observed coercivity variation [P. Galtier, R. Jerome, and T. Valet, Mater. Res. Soc. Symp. Proc. 313, 417 (1993).] It was also observed that the coercivity of the permalloy is dependent on the nature of the underlayer. It was established that the coercivity of Ni81Fe19 films increases when the thickness increased from a critical film thickness and grain size. The variation of the coercivity in thin Ni81Fe19 films with lateral grain size and relationship with domain-wall width is discussed and compared with other theories for magnetization reversal.