The emission of carbon pollutants stemming from dairy farms has emerged as a significant obstacle in mitigating the effects of global warming. China, being a prominent nation in the field of dairy farming, encounters significant challenges related to excessive component input and elevated environmental pollution. Digital technology presents an opportunity to enhance the factor allocation of dairy farms and thus increase their environmental efficiency. This study utilizes survey data from 278 dairy farms in China to examine the effect of digital technology on the allocation of land, labor, and capital variables in dairy farms. The IV-Probit model, IV-Tobit model, treatment effect model, and two-stage least square technique are employed to empirically analyze these impacts. Simultaneously, the intermediate effect model was employed to examine the mediating function of factor allocation in the effect of digital technology on environmental efficiency. The findings indicate that digital technology has the potential to greatly enhance land transfer and land utilization rates in dairy farms. Additionally, it has been observed that digital technology may lead to a decrease in both the proportion and time of labor input. Furthermore, digital technology has the potential to decrease short-term productive input while simultaneously enhancing long-term productive input within dairy farming operations. Digital technology has been found to have an indirect yet beneficial influence on environmental efficiency. This is mostly achieved through the facilitation of resource allocation, specifically in terms of land, labor, and capital aspects. The article presents a set of policy recommendations, including the promotion of extensive integration of digital technology within dairy farms, the facilitation of optimal allocation of production factors in dairy farms, and the implementation of specialized training programs focused on digital technology.