The aim was to design culturally acceptable and healthy diets with reduced energetic share of ultra-processed foods (UPF%) at no cost increment and to evaluate the impact of the change in the UPF% on diet quality. Food consumption and price data were obtained from the Household Budget Survey (n 55 970 households) and National Dietary Survey (n 32 749 individuals). Linear programming models were performed to design diets in which the mean population UPF% was reduced up to 5 % with no cost increment relative to the observed costs. The models were isoenergetic or allowed the energy content to vary according to the UPF%, and they were not constrained to nutritional goals (nutrient-free models) or maximised the compliance with dietary recommendations (nutrient-constrained models). Constraints regarding food preference were introduced in the models to obtain culturally acceptable diets. The mean population UPF% was 23·8 %. The lowest UPF% attained was approximately 10 %. The optimised diet cost was up to 20 % cheaper than the observed cost, depending on the model and the income level. In the optimised diets, the reduction in the UPF% was followed by an increase in fruits, vegetables, beans, tubers, dairy products, nuts, fibre, K, Mg, vitamin A and vitamin C in the nutrient-constrained models, compared with the observed consumption in the population. There was little variation in most nutrients across the UPF% reduction. The UPF% reduction in the nutrient-free models impacted only trans-fat and added sugar content. UPF% reduction and increase in diet quality are possible at no cost increment.