Since 1973 space missions carrying vector magnetometers have shown that most, but not all, solar system planets have a global magnetic field of internal origin. They have also revealed a surprising diversity in terms of field strength and morphology. While Jupiter’s field, like that of Earth, is dominated by a dipole moderately tilted relative to the planet’s spin axis, the fields of Uranus and Neptune are multipole-dominated, whereas those of Saturn and Mercury are highly symmetric relative to the rotation axis. Planetary magnetism originates from a dynamo process, which requires a fluid and electrically conducting region in the interior with sufficiently rapid and complex flow. The magnetic fields are of interest for three reasons: (i) they provide ground truth for dynamo theory, (ii) the magnetic field controls how the planet interacts with its space environment, for example, the solar wind, and (iii) the existence or nonexistence and the properties of the field enable us to draw inferences on the constitution, dynamics, and thermal evolution of the planet’s interior. Numerical simulations of the geodynamo, in which convective flow in a rapidly rotating spherical shell representing the outer liquid iron core of the Earth leads to induction of electric currents, have successfully reproduced many observed properties of the geomagnetic field. They have also provided guidelines on the factors controlling magnetic field strength and morphology. For numerical reasons the simulations must employ viscosities far greater than those inside planets and it is debatable whether they capture the correct physics of planetary dynamo processes. Nonetheless, such models have been adapted to test concepts for explaining magnetic field properties of other planets. For example, they show that a stable stratified conducting layer above the dynamo region is a plausible cause for the strongly axisymmetric magnetic fields of Mercury or Saturn.