Knitted fabrics are widely used in clothing because of their distinctive ability to be shaped and formed, which is fundamentally different from the behavior of woven cloth. Since stitches produce complex interactions between yarns, the macroscopic behavior of knitted fabrics depends more on their loop structure and stitch patterns than on the physical properties of the yarn. In order to explore the unique mechanical properties of knitted textiles we have developed a yarn-level model for weft-knitted fabrics that can be used in Finite Element Analysis (FEA) simulations. Producing geometric models of yarns in a knitted material is framed as an optimization problem. In this computing context, a single “cost” function is defined that captures the various required features of the final geometric model. The function is specified in such a way that finding the variable values that results in a minimum function evaluation produces the desired geometric result. The centerlines of the fabric's yarns are defined as Catmull-Rom splines, and the cost function is minimized 33 by adjusting the locations of the spline's control points. The optimization is based on physical parameters such as yarn interpenetration, length of the yarn and bending energy. The optimized models are written to a file which can be directly read by an FEA software. The results show that our approach can create yarn-level models of weft-knitted fabrics consisting of an arbitrary pattern of knit and purl stitches, with a range of sizes, that are suitable for FEA simulations.