We present the implementation of optimal control into the open source simulation package SIMPSON for development and optimization of nuclear magnetic resonance experiments for a wide range of applications, including liquid- and solid-state NMR, magnetic resonance imaging, quantum computation, and combinations between NMR and other spectroscopies. Optimal control enables efficient optimization of NMR experiments in terms of amplitudes, phases, offsets etc. for hundreds-to-thousands of pulses to fully exploit the experimentally available high degree of freedom in pulse sequences to combat variations/limitations in experimental or spin system parameters or design experiments with specific properties typically not covered as easily by standard design procedures. This facilitates straightforward optimization of experiments under consideration of rf and static field inhomogeneities, limitations in available or desired rf field strengths (e.g., for reduction of sample heating), spread in resonance offsets or coupling parameters, variations in spin systems etc. to meet the actual experimental conditions as close as possible. The paper provides a brief account on the relevant theory and in particular the computational interface relevant for optimization of state-to-state transfer (on the density operator level) and the effective Hamiltonian on the level of propagators along with several representative examples within liquid- and solid-state NMR spectroscopy.