The nervous system of an insect can be divided into a brain and a ventral nerve cord. The head capsule is made up of six fused segments, each with a pair of ganglia, or a cluster of nerve cells outside of the brain. The first three pairs of ganglia are fused into the brain, while the three following pairs are fused into a structure of three pairs of ganglia under the insect's esophagus, called the subesophageal ganglion.[1]:57

The thoracic segments have one ganglion on each side, which are connected into a pair, one pair per segment. This arrangement is also seen in the abdomen but only in the first eight segments. Many species of insects have reduced numbers of ganglia due to fusion or reduction.[2] Some cockroaches have just six ganglia in the abdomen, whereas the wasp Vespa crabro has only two in the thorax and three in the abdomen. Some insects, like the house fly Musca domestica, have all the body ganglia fused into a single large thoracic ganglion.

At least a few insects have nociceptors, cells that detect and transmit sensations of pain.[3] This was discovered in 2003 by studying the variation in reactions of larvae of the common fruitfly Drosophila to the touch of a heated probe and an unheated one. The larvae reacted to the touch of the heated probe with a stereotypical rolling behavior that was not exhibited when the larvae were touched by the unheated probe.[4] Although nociception has been demonstrated in insects, there is not a consensus that insects feel pain consciously[5] but see Pain in invertebrates.