A fundamental understanding of extracellular microenvironments of O
2
and reactive oxygen species (ROS) such as H
2
O
2
, ubiquitous in microbiology, demands high-throughput methods of mimicking, controlling, and perturbing gradients of O
2
and H
2
O
2
at microscopic scale with high spatiotemporal precision. However, there is a paucity of high-throughput strategies of microenvironment design, and it remains challenging to achieve O
2
and H
2
O
2
heterogeneities with microbiologically desirable spatiotemporal resolutions. Here, we report the inverse design, based on machine learning (ML), of electrochemically generated microscopic O
2
and H
2
O
2
profiles relevant for microbiology. Microwire arrays with suitably designed electrochemical catalysts enable the independent control of O
2
and H
2
O
2
profiles with spatial resolution of ∼10
1
μm and temporal resolution of ∼10° s. Neural networks aided by data augmentation inversely design the experimental conditions needed for targeted O
2
and H
2
O
2
microenvironments while being two orders of magnitude faster than experimental explorations. Interfacing ML-based inverse design with electrochemically controlled concentration heterogeneity creates a viable fast-response platform toward better understanding the extracellular space with desirable spatiotemporal control.