Yarn density, or yarn count, in a woven fabric is an important parameter that influences fabric structure and properties. The measurement of yarn density often involves tedious, inaccurate procedures. This paper presents a new method developed for rapid and accurate measurement of yarn density. The method takes advantage of the structural features of a woven fabric, and uses a computer-generated grating (a reference pattern) to produce digital moire interference on the fabric. The moire image is then demodulated and processed with a phase-shifting technique so that moire fringes can be extracted and counted. From the relation between the pitches of the grating and the moire fringes, the yarn density can be calculated. This technique does not need complicated optical setting or an interferometer to form moire fringes with fabrics, permitting fast and accurate measurement of yarn densities.