There are eight sovereign states that have successfully detonated nuclear weapons. Five are considered to be nuclear-weapon states (NWS) under the terms of the Treaty on the Non-Proliferation of Nuclear Weapons (NPT). In order of acquisition of nuclear weapons these are: the United States, Russia (the successor state to the Soviet Union), the United Kingdom, France, and China.
Since the NPT entered into force in 1970, three states that were not parties to the Treaty have conducted nuclear tests, namely India, Pakistan, and North Korea. North Korea had been a party to the NPT but withdrew in 2003.
Israel is also generally understood to have nuclear weapons, but does not acknowledge it, maintaining a policy of deliberate ambiguity, and is not known definitively to have conducted a nuclear test. Israel is estimated to possess somewhere between 75 and 400 nuclear warheads. One possible motivation for nuclear ambiguity is deterrence with minimum political cost.
States that formerly possessed nuclear weapons are South Africa (developed nuclear weapons but then disassembled its arsenal before joining the NPT) and the former Soviet republics Belarus, Kazakhstan, and Ukraine.