Among the main contributors to CO2 emissions on the ozone layer, the construction industry contributes with a significant portion. This emission is generated largely by applying concrete construction systems and their variations. Therefore, it is important to use tools that allow the development of projects which mitigate the effects of harmful gas emissions into the atmosphere. Thus, this study applied an optimization algorithm called Firefly Algorithm (FA) to design precast and prestressed rectangular beams focusing on reducing CO2 emissions in the structural design phase. The Objective Function (OF) was defined as the total weight of CO2 emitted in each construction phase (production, transportation, and placement) and the structural design constraints are based on the design criteria established in ABNT NBR 6118. The problem optimization’s variables are geometric properties and mechanical beam's conditions, where the beam height, beam width, the proportion of height generates prestressing eccentricity, and the proportion of prestressing load were considered as design variables. Ten beams were analyzed, with different loadings, where each of these beams was submitted to the optimization process thirty times. For the proposed conditions, the ten beams had an average CO2 emission of 3282.59 kg, maximum and minimum carbon emission of 3630.52 kg and 2910.67 kg, respectively. The study resulted in a feasibility rate higher than 90%, showing that the optimization tool was efficient in the structural design phase focusing on sustainability. Concerning carbon emission, it is possible to verify a relationship between the increase of emission and the load since element with greater inertia tend to emit a greater amount of CO2. It was also possible to determine a regression between carbon emission and beam load.