The upper atmosphere of the Sun is governed by the complex structure of the magnetic field. This controls the heating of the coronal plasma to over a million kelvin. Numerical experiments in the form of three-dimensional magnetohydrodynamic simulations are used to investigate the intimate interaction between magnetic field and plasma. These models allow one to synthesize the coronal emission just as it would be observed by real solar instrumentation. Large-scale models encompassing a whole active region form evolving coronal loops with properties similar to those seen in extreme ultraviolet light from the Sun, and reproduce a number of average observed quantities. This suggests that the spatial and temporal distributions of the heating as well as the energy distribution of individual heat deposition events in the model are a good representation of the real Sun. This provides evidence that the braiding of fieldlines through magneto-convective motions in the photosphere is a good concept to heat the upper atmosphere of the Sun.