Thermal expansion and atomic structure of amorphous silicon nitride (SiNx) thin films were investigated. SiNx films of different Si/N compositions were formed by changing the SiH4/NH3 source gas ratio in plasma enhanced chemical vapor deposition (PE-CVD). The measurements of high temperature stress and hydrogen desorption demonstrated that the more Si-rich composition of SiNx led to less thermal expansion and more hydrogen desorption from Si-H bonds between 650°C and 800°C. In case the SiNx is Si-rich and contains both Si-H and N-H bonds, the Si and N atoms bond together after the hydrogen desorption. The increase of Si-N bonds should shrink the SiNx film and suppress the thermal expansion.