Objective To build a method for calculating the optimal length of hamstring muscles in vivo, and make comparison with other indirect parameters which represent the optimal length. Methods By synchronously recording knee flexion torque and kinematic data, the musculoskeletal model of lower limbs was built to obtain hamstring strength and muscle length, and to further calculate the optimal length of hamstring muscles. Results Flexion angle at peak knee flexion torque was significantly greater than that at peak hamstring strength and their correlation coefficient was 0.741. The optimal lengths of each bi-articulated hamstring muscles were significantly greater than the corresponding muscle lengths during standing and their correlation coefficients was low. Conclusions The established estimating method for optimal length of hamstring muscles provided references for future studies on injury mechanism and risk factors. Flexion angle at peak knee flexion torque could partly represent the optimal length of hamstring. It is not suggested that hamstring muscle length during standing should be used as an approximation of hamstring optimal length.