The aim of this paper is to optimize modular systems which cover the construction of products that can be assembled on a modular basis. Increasing the number of different variants of individual components on the one hand decreases the cost of oversizing the assembled product, while on the other hand the cost for maintaining the modular system increases. For the minimization of the overall cost a mixed-integer optimization problem is derived. The problem cannot simply be passed to a solver for mixed-integer optimization problems, since certain dependency structures of the variables occur by which in the beginning it is not even clear how many decision variables the problem has. We propose a solution approach using binary variables to transform the problem into a mixed-integer single-level problem, for which standard solvers can be used. In a numerical study, this formulation is investigated using the example of a modular system for crane bridges, and it is shown that the problem formulation as a single-level problem possesses potential also for the optimization of other modular systems.