Tar-rich coal, a valuable resource for China's energy security, undergoes the production of tar and gas during pyrolysis. This study combines proximate and ultimate analyses with TGA and in-situ FTIR to investigate the molecular structure of raw coal and its macerals from three coal-forming environments. The results indicate that the paleosedimentary environment significantly affects coal structure, especially the aliphatic and aromatic structures, as well as oxygenated functional groups. Deeper overlying water and more reducing conditions foster the formation of aliphatic structures, which are abundant in vitrinite-rich concentrates and raw coal, whereas inertinite-rich concentrates contain fewer. During pyrolysis, aromatic C-H condensation results in the formation of semi-coke and coke. Raw coal and macerals from deeper, reducing environments decompose more rapidly, accelerating aromatic condensation. Additionally, volatile gases such as H₂, CO, CO₂, CH₄, and tar are generated during pyrolysis. CO and CO₂ mainly originate from the cracking of oxygenated functional groups. Xinjiang raw coal(T1-R(V)), formed under deep overlying water, exhibits intense decomposition due to the high content of oxygenated functional groups in aliphatic side chains. Xiwan coal(T3), from a wet forest swamp environment, has numerous oxygenated groups, leading to higher decomposition rates in raw coal and inertinite-rich concentrates. Aliphatic cracking releases hydrocarbon gases and tar, with faster decomposition occurring in deeper, reducing environments. The thermal decomposition rates of vitrinite-rich concentrates show minimal variation. These findings underscore the influence of coal-forming environments on pyrolysis, facilitating the efficient utilization of tar-rich coal.