Photonic crystals (PhCs) are nano-engineered materials that allow extraordinary control over the flow of light. These structures can be fabricated out of common semiconductors, are compatible with existing technologies, and are expected to play a major role in future devices integrating photonic circuits, e.g. for telecommunication applications or quantum cryptography. PhC devices are in fact tremendously flexible, and their features are affected by a large number of controllable parameters. This is on one hand a great advantage, but on the other a great challenge when it comes to finding the optimal device for a given application. To face this challenge, we have developed an automated optimization procedure that combines a fast algorithm for the simulation of a single PhC structure with a global optimization algorithm for the exploration of the parameter space. This was applied to various devices of interest to the community, and inevitably resulted in a vast improvement of their qualities. The procedure is thus bound to play a major role in the future development of the field, and to promote the transition from science to technology.