During the final stages of World War II in 1945 the cities of Hiroshima and Nagasaki were bombed. These cities were bombed to end the war. This also was one of the consequences for attacking Pearl Harbor. The Americans believed that the number of people saved by ending the WWII would be greater than the number of people killed by the bomb.
On July 26, Truman along with other Allies made the Potsdam Ultimatum stating that if Japan didn’t surrender, they would attack Japan. Japan didn’t surrender. Instead they trained everyone, even civilians, to be ready for the attack of the US. The bomb was not mentioned on the ultimatum.
To avoid an invasion and save lives, the USA drops atomic bombs on two Japanese cities, Hiroshima and Nagasaki on August 6 and 8 1945. Japan then surrenders.