Fish trophic niches reflect important ecological interactions and provide insight into the structure of mangrove food webs. Few studies have been conducted in mangrove fish predators to investigate interpopulation trophic niches and ontogenetic shifts. Using stable isotope analysis and two complementary approaches, the authors investigated trophic niche patterns within and between two ontogenetic groups (juveniles and sub‐adults) of a generalist predator (Acentrogobius viridipunctatus) in four mangroves with heterogeneous environmental conditions (e.g., tidal regimes, salinity fluctuations and mangrove tree community). The authors hypothesized that the trophic niche between populations would vary regionally and trophic position would increase consistently from juvenile to sub‐adult stages. The results revealed that both δ13C and δ15N values varied greatly across populations and between ontogenetic groups, and complex spatio‐ontogenetic variations were expressed by Layman's metrics. They also found some niche separation in space, which is most likely related to resource availability in spatially diverse ecosystems. In addition, trophic niche position increased consistently from juveniles to sub‐adults, indicating ontogenetic feeding shifts. The isotopic plasticity index and Fulton's condition index also showed significant spatial‐ontogenetic variation, which is consistent with optimal foraging theory. The findings highlight that trophic plasticity has a high adaptive value for mangrove fish predators in dynamic ecosystems.