Cokes are inevitably generated during zeolite-catalyzed reactions as deleterious side products that deactivate the catalyst. In this study, we in-situ converted cokes into carbons within the confined microporous zeolite structures and evaluated their performances as absorbing materials for solar-driven water evaporation. With a properly chosen zeolite, the cokederived carbons possessed ordered interconnected pores and tunable compositions. We found that the porous structure and the oxygen content in as-prepared carbons had important influences on their energy conversion efficiencies. Among various investigated carbon materials, the carbon derived from the methanol-to-olefins reaction over zeolite Beta gave the highest conversion efficiency of 72% under simulated sunlight with equivalent solar intensity of 2 suns. This study not only demonstrates the great potential of traditionally useless cokes for solar thermal applications but also provides new insights into the design of carbon-based absorbing materials for efficient solar evaporation.