Invertebrates are a wildly diverse lot—far more diverse than the relatively small group known as vertebrates. Accordingly, the inverts have a huge diversity of life styles and body plans. Consider (for now) just the inverts that breathe air (and temporarily leave aside those that get oxygen from water).
Some invertebrates have lungs, although they are quite different from vertebrate lungs. Many snails have a well-vascularized lung derived from the mantle (that’s the tissue that makes the body cavity and surrounds the internal organs; it also secretes the shell). The mantle forms a thin-walled pouch that opens to the outside. Air enters the pouch and the oxygen diffuses into the blood. But, unlike the vertebrates, the blood is not contained in blood vessels (such as capillaries) but rather fills spaces in the body cavity. In these snails (and most other molluscs), oxygen is carried in solution (not in blood cells) by molecules of copper-containing hemocyanin (in contrast to vertebrates’ iron-containing hemoglobin); the blood is bluish when oxygenated. This arrangement is common among terrestrial snails and some freshwater snails that come to the surface to get air, and it also occurs in a few intertidal or estuarine marine species.
Land crabs have a sort of lung, made from a modified gill chamber. Functional gills are rudimentary or absent. The coconut crab is an example: this huge crab is related to hermit crabs but it is terrestrial, using lungs to breathe. Most terrestrial arthropods (crabs, spiders, insects etc.) have some form of hemocyanin in the blood. However, the larvae of certain midges, sometimes known as blood worms, are exceptional in that they capture oxygen with a type of hemoglobin (so they are red-colored).
Most spiders have structures called ‘book-lungs’, but these are quite unlike the lungs of vertebrates or snails or land crabs. They open to the outside underneath the front part of the abdomen and consist of a set of sacs, each containing parallel rows of thin blood-filled sheets separated by air passages (?like the leaves of a book?). Gas exchange occurs there, but in addition, spiders also have ‘tracheae’, which open to the outside via a spiracle; they are reinforced air-filled tubes that branch through the body.
Air-breathing insects generally depend on a tracheal system to deliver oxygen to the cells. Spiracles in the external skeleton lead to branching ‘trees’ of ever-smaller tracheae—the smallest ones reach individual cells (as in spiders too). Oxygen comes in through the tracheae and carbon dioxide goes out. Although the tracheal system is slightly supplemented by blood that moves around in the body cavity (not in blood vessels), the main function of insect blood is not respiratory; it serves mainly to move food from the digestive tract and waste products to the excretory organs, as well as hormones to particular tissues.
Some aquatic insects breathe air too. For example, rat-tailed maggots are the aquatic larvae of certain hoverflies (a.k.a. flowerflies) that pollinate flowers. A submerged larva has a tube at the end of its abdomen that reaches up to the surface of the water, where air can enter the tube. Some aquatic mosquito larvae do this too. Naturalists sometimes liken this habit to snorkeling.
Other aquatic insects take air with them when they submerge. Predaceous diving beetle adults have spiracles on the abdomen under the tips of the wing covers. An adult can rest at the surface with its head down and raise the wing covers to expose the spiracles to the air—and thus breathe air while resting there. When it dives, it can store air under the wing covers. Water boatmen have undersides covered with dense, unwettable hairs that trap a sheet of water up against the spiracles of the abdomen. These reservoirs of trapped air can exchange gases with the water and thus replenish the initial supply of oxygen.
Extremely small terrestrial invertebrates don’t have special respiratory systems at all. They are so small that there is a lot of surface area relative to the body volume, and oxygen and carbon dioxide just diffuse through the exterior covering. Similarly, earthworms, with their long thin shape and lots of surface area per unit of volume, just accomplish gas exchange through their moist skin.