Liquid nitrogen (LN2) fracturing is a potential stimulation method in unconventional hydrocarbon recovery, showing its merits in being water free, creating low formation damage and being environmentally friendly. The microstructure evolution of rocks subjected to LN2 cooling is a fundamental concern for the engineering application of LN2 fracturing. In this paper, pore-scale imaging and characterization were performed on two rocks, i.e., tight sandstone and coal specimens subjected to LN2 cooling using computed tomography scanning. The digital core technique was employed to reconstruct the microstructures of rocks and give a quantitative analysis of the pore structure evolution of both dry and water-saturated rocks. The results indicate that LN2 cooling has a great effect on the pores’ morphology and their spatial distribution, leading to a great improvement in pore diameter and aspect ratio. When compared to the sandstone, coal is more sensitive to LN2 cooling and thermal stresses, having a more noticeable growth in pore–throat size. The porosity growth of coal is 291% higher than that of sandstone. There is a growing trend in the irregularity and complexity of pore structures. After LN2 cooling, the fractal dimensions of the pores of sandstone and coal grow by 11.7% and 0.87%, respectively, and the proportion of pores with a shape factor > 100 increases. More bundle-like and strip-shape pores with multiple branches are generated, which causes a significant growth in the throat size and the proportion of connected pores with a coordination number ≥ 1, enhancing the complexity and connectivity of pore structures dramatically. Additionally, pore water plays an important role in aggravating rock damage during LN2 cooling, enhancing the pore space and connectivity. The porosities of the saturated sandstone and coal samples grow by 22.6% and 490.4%, respectively, after LN2 cooling, which are 5.6% and 186.6% higher than dry samples. The generation of macropores ≥ 70 μm is the primary contributor to porosity growth during LN2 cooling, although such pores account for only a small proportion of the total. These findings contribute to our understanding of the microscopic mechanism of LN2 cooling on rock damage and may provide some guidance for the engineering application of LN2 fracturing.