A linear programming model that selects the optimal cropping plan and feeds allocation for diets to minimize the whole dairy farm feed costs was developed. The model was virtually applied on 29 high-yielding Holstein-Friesian herds, confined, total mixed ration dairy farms. The average herd size was 313.2 ± 144.1 lactating cows and the average land size was 152.2 ± 92.5 ha. Farm characteristics such as herd structure, nutritional grouping strategies, feed consumption, cropping plan, intrinsic farm limitations (e.g., silage and hay storage availability, water for irrigation, manure storage) and on farm produced forage costs of production were collected from each farm for the year 2017. Actual feeding strategies, land availability, herd structure, crop production costs and yields, and milk and feed market prices for the year 2017 were used as model inputs. Through optimization, the feeding system was kept equal to the actual farm practice. The linear program formulated diets for each animal group to respect actual herd dry matter intake and fulfill actual consumption of crude protein, rumen-degradable and rumen-undegradable fractions of crude protein, net energy for lactation, neutral detergent fiber, acid detergent fiber, forage neutral detergent fiber, and nonfiber carbohydrate. Production levels and herd composition were considered to remain constant as the nutritional requirement would remain unchanged. The objective function was set to minimize the whole-farm feed costs including cash crop sales as income, and crop production costs and purchased feed costs as expenses. Optimization improved income over feed costs by reducing herd feed costs by 7.8 ± 6.4%, from baseline to optimized scenario, the improved was explained by lower feed costs per kilogram of milk produced due to a higher feed self-sufficiency and higher income from cash crop. In particular, the model suggested to maximize, starting from baseline to optimized scenario, the net energy for lactation (+8.5 ± 6.3%) and crude protein (+3.6 ± 3.1%) produced on farm, whereas total feed cost (€/100 kg of milk) was greater in the baseline (20.4 ± 2.3) than the optimized scenario (19.0 ± 1.9), resulting in a 6.7% feed cost reduction with a range between 0.49% and 21.6%. This meant €109 ± 96.9 greater net return per cow per year. The implementation of the proposed linear programming model for the optimal allocation of the nutritional resources and crops in a dairy herd has the potential to reduce feed cost of diets and improve the farm feed self-sufficiency.