The production of chemical energy carriers utilizing electrical energy from renewable sources is essential for the future energy system. A motored piston engine may be used as a reactor to convert mechanical to chemical energy by the pyrolysis of methane and ethane; this is analyzed here. The piston engine is modeled as a compression–expansion cycle with detailed chemical kinetics. The main products are hydrogen and high‐energy hydrocarbons such as acetylene, ethylene, and benzene. To reach the required high temperatures for conversion after compression, the educt is diluted with argon. The influence of the operating conditions (temperature, pressure, dilution) on the product gas composition, the stored exergy, and the ratio of exergy gain to work input (efficiency) is investigated. A conversion of >80% is predicted for an argon dilution of 93 mol% at inlet temperatures of 573 K (methane) and 473 K (ethane), respectively. A storage power of 7.5 kW (methane) and 6 kW (ethane) for a 400 ccm four‐stroke single‐cylinder is predicted with an efficiency of 75% (methane) and 70% (ethane), respectively. Conditions are identified, where high yields of the target species are achieved, and soot formation can be avoided.