The diet of the rainbow pitta is dominated by insects and their larvae, other arthropods, snails and earthworms. Near Darwin, two thirds of the diet was earthworms; these are mostly taken during the rainy season from October to April. Insects and other arthropods are more commonly taken in the dry season; insects and arthropods taken include cockroaches, beetles, ants, caterpillars and grasshoppers, centipedes, spiders and millipedes. It will also take "Carpentaria" fruits that have fallen to the ground, as well as frogs and lizards. The species forages individually by hopping on the forest floor, then pausing to scan; leaves and soil are scratched by the feet and leaves may be flicked away by the bill. When feeding on snails, it breaks them out of the shells using roots as an anvil. Unlike the noisy pitta, it only uses roots and branches as anvils, not stones. Larger prey like large centipedes are shaken and dropped, then the bird retreats for a few seconds before repeating the process. The rainbow pitta is monogamous during the breeding season, but does not form lifelong bonds. A pair may stay together the following year after breeding, but they are more likely to find new partners. Breeding in this species is seasonal, running from December through April. The first rains of the rainy season seem to be the trigger for nest building, as the breeding season seems to be correlated with the availability of earthworms, a major part of the diet of both nestlings and adults during this time. Breeding territories vary in size from ; territories are larger in drier forest. Nesting sites are placed randomly through the pair's territory, although second nests in a year are placed some distance from nests used earlier that season. Nests are not used more than once; if the pair lay a new clutch in a season then a new nest is constructed. Unlike the noisy pitta, which mostly places its nests close to the ground, the rainbow pitta only rarely places its nest close to the ground, possibly because its habitat floods more readily. It does place its nest anywhere from ground level up to up a tree, and the same pair can show similar variation in location within a nesting season. The nest can be placed in the fork of a tree, at the top of palms, on horizontal branches, in tangles of vines or against the buttress roots of a tree. A nest takes about a week to build, and is built by both parents.