The water level control system implicated in the nuclear steam generator has played an essential role in unexpected shutdowns of the power plant. According to reports, about 25% of the emergency power blackouts are caused by improper level control systems. The effectiveness of optimization methods in designing a controller is currently proved in different disciplines. The novelty of this paper is the proportional integral derivative (PID) controller tuning of nuclear steam generator by particle swarm optimization (PSO) and genetic algorithm (GA) for the lowest steady-state error, overshoot, undershoot, and settling time. Different types of the cost function are employed to obtain the controller gains. The integral of the absolute error (IAE), square error (ISE), time-weighted average error (ITAE), time-weighted square error (ITSE), and a weighted function based on overshoot, undershoot, and settling time are used. The gain scheduling of optimized PIDs is used to have an entire operating range control system. The desired load-following and stability of the optimized PID controller are investigated under both time and frequency domains using trajectory tracking, disturbance rejection, and Nichols chart criterion.