The sound of thunder is a result of the rapid heating of air by lightning strikes. As the lightning heats the air it expands and compresses creating a rippling shock wave that creates the noise we know as thunder. Generally, the loudest thunder occurs near the lightning strike site.
Thunder can also be a lot louder when the lightning strikes at higher altitudes. This happens because of a meteorological phenomenon called a temperature inversion. A temperature inversion causes warm air to be wedged above cooler surface air. This allows sound waves to move faster in the warmer air. This can cause them to be refracted and bent back toward the ground, causing additional sounds that can amplify the sound of thunder.
In addition, the shape of the lightning strike can affect how loud thunder is. Lightning that shoots straight down will produce a short sharp sound, while lightning that forms a cylinder will have a much longer rumble.
While thunder is generally safe for people to hear, it can still be dangerous if you are close to the point of contact with the ground. On average, 20% of people struck by lightning die. So be sure to stay safe by staying inside when storms arrive.
If you want to learn more about thunderstorms and how they work be sure to check out this article by WJXT News4Jax. It provides great background information about thunder and how the sound of it varies depending on your location.