Understanding the drivers of energy and material flows of cities is important for addressing global environmental challenges. Accessing, sharing, and managing energy and material resources is particularly critical for megacities, which face enormous social stresses because of their sheer size and complexity. Here we quantify the energy and material flows through the world's 27 megacities with populations greater than 10 million people as of 2010. Collectively the resource flows through megacities are largely consistent with scaling laws established in the emerging science of cities. Correlations are established for electricity consumption, heating and industrial fuel use, ground transportation energy use, water consumption, waste generation, and steel production in terms of heating-degree-days, urban form, economic activity, and population growth. The results help identify megacities exhibiting high and low levels of consumption and those making efficient use of resources. The correlation between per capita electricity use and urbanized area per capita is shown to be a consequence of gross building floor area per capita, which is found to increase for lower-density cities. Many of the megacities are growing rapidly in population but are growing even faster in terms of gross domestic product (GDP) and energy use. In the decade from 2001-2011, electricity use and ground transportation fuel use in megacities grew at approximately half the rate of GDP growth.