ABSTRACT Active star-forming regions are excellent laboratories for studying the origins and evolution of young stellar object (YSO) clustering. The W40–Serpens South region is such a region, and we compile a large near- and mid-infrared catalogue of point sources in it, based on deep near-infrared observations of Canada-France-Hawaii Telescope (CFHT) in combination with Two Micron All Sky Survey (2MASS), UKIRT Infrared Deep Sky Survey (UKIDSS), and Spitzer catalogues. From this catalogue, we identify 832 YSOs, and classify 15, 135, 647, and 35 of them to be deeply embedded sources, Class I YSOs, Class II YSOs, and transition disc sources, respectively. In general, these YSOs are well correlated with the filamentary structures of molecular clouds, especially the deeply embedded sources and the Class I YSOs. The W40 central region is dominated by Class II YSOs, but in the Serpens South region, half of the YSOs are Class I. We further generate a minimum spanning tree (MST) for all the YSOs. Around the W40 cluster, there are eight prominent MST branches that may trace the vestigial molecular gas filaments that once fed gas to the central natal gas clump. Of the eight, only two now include detectable filamentary gas in Herschel data and corresponding Class I YSOs, while the other six are populated exclusively with Class II YSOs. Four MST branches overlap with the Serpens South main filament, and where they intersect, molecular gas ‘hubs’ and more Class I YSOs are found. Our results imply a mixture of YSO distributions composed of both primordial and somewhat evolved YSOs in this star-forming region.