Abstract Background Benefits of green spaces (GS) on sleep quality were found, particularly for mothers, which, in turn, contributed to maternal health and offspring development. However, the COVID-19 pandemic imposed restrictions on environmental access, potentially altering the influence of urban GS on sleep quality. This study aims to explore the impact of urban GS on maternal sleep quality one year postpartum during the pandemic. Methods Participants were drawn from the Longitudinal Examination across Prenatal and Postpartum Health in Taiwan study, tracking individuals from early pregnancy across five hospitals in Taipei since 2011. We utilized data spanning from 2019 to 2024, with May 2021 (the initial soft lockdown due to community spread) serving as the cutoff point to delineate early and late pandemic stages. Self-reported sleep quality one year postpartum was assessed using the Pittsburgh Sleep Quality Index. Residential GS was evaluated using the Normalized Difference Vegetation Index (NDVI) within various radii (250m to 2000m). Multiple logistic regression was utilized. Results From the 311 participants, in the early stage of the pandemic, an increase of 0.1 units in NDVI within a 250m radius during both prenatal and postnatal periods (0-12 months) was associated with improved maternal sleep quality (OR = 1.57; 95% CI = 1.08, 2.32, and OR = 1.58; 95% CI = 1.07, 2.30) after adjustments. The impact diminished as the radius increased. Additionally, no significant association was found during the late stage of the pandemic across any of the studied radii. Conclusions The findings suggest a positive correlation between proximity to urban GS and maternal sleep quality during the early stages of the pandemic, with more significant benefits observed at shorter distances, likely due to restricted movement and access. These results underscore the importance of proximity in urban planning and environmental improvement initiatives aimed at enhancing maternal and child health. Key messages • Urban green spaces significantly enhance maternal sleep quality one year postpartum in the early stages of the pandemic, highlighting the importance of proximity for health benefits. • As the radius of green spaces decreased, their positive impact on maternal sleep quality during the early pandemic intensified, underscoring the need for adaptive urban planning strategies.