Electromagnetic arrangements which create a magnetic field of required distribution and magnitude are widely used in electrical engineering. Development of new accurate designing methods is still a valid topic of technical investigations. From the theoretical point of view the problem belongs to magnetic fields synthesis theory. This paper discusses a problem of designing a shape of a solenoid which produces a uniform magnetic field on its axis. The method of finding an optimal shape is based on a genetic algorithm (GA) coupled with Bézier curves.