Ingestible electronics can potentially be used to track and treat gastrointestinal diseases in real time. In the past decade, substantial improvements have been made to ingestible electronic pills at the sensor, circuit and system levels, which has improved the clinical applicability of the technology by increasing device sensitivity, lifetime and location awareness. Here we explore the development of ingestible electronics and provide a step-by-step guide for the design of ingestible capsules at the system level. We consider the anatomical and physiological characteristics of gastrointestinal organs, which set requirements and constraints on ingestible electronics in terms of size, shape, topology and the materials used for packaging. We then examine the key design components: sensors and actuators, integrated circuits, communication, power, packaging, localization and locomotion. We also consider the challenges that must be addressed to realize the full application potential of ingestible electronics.