Mastitis is an important disease from an economic perspective, but most cost assessments of mastitis include only the direct costs associated with the disease (e.g., production losses, culling, and treatment), which we call failure costs (FC). However, farmers also invest time and money in controlling mastitis, and these preventive costs (PC) also need to be taken into account. To estimate the total costs of mastitis, we estimated both FC and PC. We combined multiple test-day milk records from 108 Dutch dairy farms with information on applied mastitis prevention measures and farmers’ registration of clinical mastitis for individual dairy cows. The aim was to estimate the total costs of mastitis and to give insight into variations between farms. We estimated the average total costs of mastitis to be 240/lactating cow per year, in which FC contributed 120/lactating cow per year and PC contributed another 120/lactating cow per year. Milk production losses, discarded milk, and culling were the main contributors to FC, at 32, 20, and 20/lactating cow per year, respectively. Labor costs were the main contributor to PC, next to consumables and investments, at 82, 34, and 4/lactating cow per year, respectively. The variation between farmers was substantial, and some farmers faced both high FC and PC. This variation may have been due to structural differences between farms, different mastitis-causing pathogens, the time at which preventive action is initiated, stockmanship, or missing measures in PC estimates. We estimated the minimum FC to be 34 per lactating cow per yr. All farmers initiated some preventive action to control or reduce mastitis, indicating that farmers will always have mastitis-related costs, because mastitis will never be fully eradicated from a farm. Insights into both the PC and FC of a specific farm will allow veterinary advisors and farmers to assess whether current udder health strategies are appropriate or whether there is room for improvement from an economic perspective.