In this paper, a nonlocal energy‐informed neural network is proposed to characterize the deformation behaviors of elastic solids with cracks subjected to thermomechanical loads in the framework of ordinary state‐based peridynamics. Based on principle of virtual work, a nonlocal energy approach is developed to recast the solution to peridynamic equilibrium equation as a problem of minimizing the potential energy of the system, which automatically satisfies the traction‐free boundary conditions. Meanwhile, the energy representation of physical system can be treated as the loss function for machine learning methods. Therefore, a nonlocal energy‐informed neural network is constructed to approximate the solution of the system. A distinct advantage of the proposed neural network is that the strain energy is expressed in terms of spatial integration instead of spatial derivatives, which avoids the invalidation of automatic differentiation at the crack surfaces in original physics‐informed neural networks. To demonstrate the convergence and accuracy of the proposed neural network, a series of problems in solid and fracture mechanics are conducted, and compared with results from analytical solutions or classical numerical methods. Additionally, for elastic material containing initial cracks, displacement extrapolation method is encoded into the proposed neural network to evaluate the static stress intensity factor.