Pore structure is an important parameter to quantify the reservoir rock adsorption capability and diffusivity, both of which are fundamental reservoir properties to evaluate the gas production and carbon sequestration potential for coalbed methane (CBM) and shale gas reservoirs. In this study, we applied small-angle neutron scattering (SANS) to characterize the total and accessible pore structures for two coal and two shale samples. We carried out <
em>
in situ<
/em>
SANS measurements to probe the accessible pore structure differences under argon, deuterated methane (CD<
sub>
4<
/sub>
), and CO<
sub>
2<
/sub>
penetrations. The results show that the total porosity ranges between 0.25 and 5.8% for the four samples. Less than 50% of the total pores are accessible to CD<
sub>
4<
/sub>
for the two coals, while more than 75% of the pores were found to be accessible for the two shales. This result suggests that organic matter pores tend to be disconnected compared to mineral matter pores. Argon pressurization can induce pore contraction because of the mechanical compression of the solid skeleton in both the coal and shale samples. Hydrostatic compression has a higher effect on the nanopores of coal and shale with a higher accessible porosity. Both methane and CO<
sub>
2<
/sub>
injection can reduce the accessible nanopore volume due to a combination of mechanical compression, sorption-induced matrix swelling, and adsorbed molecule occupation. CO<
sub>
2<
/sub>
has higher effects on sorption-induced matrix swelling and pore filling compared to methane for both the coal and shale samples. Gas densification and pore filling could occur at higher pressures and smaller pore sizes. In conclusion, the compression and adsorption could create nanopores in the San Juan coal and Marcellus shale drilled core but could have an opposite effect in the other samples, namely, the processes could damage the nanopores in the Hazleton coal and Marcellus shale outcrop.