Armed forces personnel, total

Source: worldbank.org, 03.09.2025

Year: 2020

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 165,000 -40.6% 37
Angola Angola 117,000 0% 48
Albania Albania 8,000 0% 101
United Arab Emirates United Arab Emirates 63,000 0% 60
Argentina Argentina 103,000 0% 52
Armenia Armenia 47,000 -4.08% 68
Antigua & Barbuda Antigua & Barbuda 0 109
Australia Australia 60,000 +1.69% 61
Austria Austria 23,000 +4.55% 86
Azerbaijan Azerbaijan 82,000 0% 54
Burundi Burundi 31,000 -39.2% 79
Belgium Belgium 24,000 -7.69% 85
Benin Benin 12,000 0% 97
Burkina Faso Burkina Faso 11,000 0% 98
Bangladesh Bangladesh 227,000 0% 29
Bulgaria Bulgaria 37,000 0% 75
Bahrain Bahrain 19,000 0% 90
Bahamas Bahamas 2,000 0% 107
Bosnia & Herzegovina Bosnia & Herzegovina 11,000 0% 98
Belarus Belarus 158,000 +1.94% 38
Belize Belize 2,000 0% 107
Bolivia Bolivia 71,000 0% 58
Brazil Brazil 762,000 0% 8
Barbados Barbados 1,000 0% 108
Brunei Brunei 8,000 0% 101
Botswana Botswana 9,000 0% 100
Central African Republic Central African Republic 10,000 0% 99
Canada Canada 72,000 0% 57
Switzerland Switzerland 20,000 0% 89
Chile Chile 114,000 -6.56% 50
China China 2,535,000 0% 2
Côte d’Ivoire Côte d’Ivoire 27,000 -79.9% 82
Cameroon Cameroon 34,000 0% 77
Congo - Kinshasa Congo - Kinshasa 134,000 0% 45
Congo - Brazzaville Congo - Brazzaville 12,000 97
Colombia Colombia 428,000 -11% 17
Cape Verde Cape Verde 1,000 0% 108
Costa Rica Costa Rica 10,000 0% 99
Cuba Cuba 76,000 0% 56
Cyprus Cyprus 13,000 -18.8% 96
Czechia Czechia 27,000 +8% 82
Germany Germany 183,000 -0.543% 35
Djibouti Djibouti 13,000 0% 96
Denmark Denmark 15,000 0% 94
Dominican Republic Dominican Republic 71,000 0% 58
Algeria Algeria 326,000 +2.84% 21
Ecuador Ecuador 42,000 0% 72
Egypt Egypt 836,000 0% 7
Eritrea Eritrea 202,000 0% 31
Spain Spain 199,000 0% 32
Estonia Estonia 7,000 0% 102
Ethiopia Ethiopia 138,000 0% 43
Finland Finland 22,000 -18.5% 87
Fiji Fiji 4,000 0% 105
France France 304,000 0% 23
Gabon Gabon 7,000 0% 102
United Kingdom United Kingdom 153,000 +2.68% 40
Georgia Georgia 26,000 0% 83
Ghana Ghana 16,000 0% 93
Guinea Guinea 13,000 0% 96
Gambia Gambia 4,000 0% 105
Guinea-Bissau Guinea-Bissau 4,000 0% 105
Equatorial Guinea Equatorial Guinea 1,000 0% 108
Greece Greece 147,000 0% 41
Guatemala Guatemala 43,000 0% 71
Guyana Guyana 3,000 0% 106
Honduras Honduras 23,000 0% 86
Croatia Croatia 20,000 +11.1% 89
Haiti Haiti 1,000 0% 108
Hungary Hungary 46,000 +15% 69
Indonesia Indonesia 676,000 0% 9
India India 3,068,000 +0.755% 1
Ireland Ireland 9,000 0% 100
Iran Iran 650,000 0% 10
Iraq Iraq 459,000 +34.6% 15
Iceland Iceland 0 109
Israel Israel 178,000 0% 36
Italy Italy 338,000 -1.17% 20
Jamaica Jamaica 6,000 0% 103
Jordan Jordan 116,000 0% 49
Japan Japan 261,000 0% 27
Kazakhstan Kazakhstan 71,000 0% 58
Kenya Kenya 24,000 -17.2% 85
Kyrgyzstan Kyrgyzstan 21,000 0% 88
Cambodia Cambodia 191,000 0% 33
South Korea South Korea 569,000 -7.18% 11
Kuwait Kuwait 25,000 0% 84
Laos Laos 129,000 0% 46
Lebanon Lebanon 80,000 0% 55
Liberia Liberia 2,000 0% 107
Libya Libya 0 109
Sri Lanka Sri Lanka 317,000 0% 22
Lesotho Lesotho 2,000 0% 107
Lithuania Lithuania 37,000 0% 75
Luxembourg Luxembourg 1,000 0% 108
Latvia Latvia 9,000 +50% 100
Morocco Morocco 246,000 0% 28
Moldova Moldova 6,000 0% 103
Madagascar Madagascar 22,000 0% 87
Mexico Mexico 341,000 +3.96% 19
North Macedonia North Macedonia 16,000 0% 93
Mali Mali 41,000 +95.2% 73
Malta Malta 2,000 0% 107
Myanmar (Burma) Myanmar (Burma) 463,000 -9.75% 14
Montenegro Montenegro 12,000 0% 97
Mongolia Mongolia 18,000 0% 91
Mozambique Mozambique 11,000 0% 98
Mauritania Mauritania 21,000 0% 88
Mauritius Mauritius 3,000 0% 106
Malawi Malawi 15,000 0% 94
Malaysia Malaysia 136,000 0% 44
Namibia Namibia 16,000 0% 93
Niger Niger 10,000 0% 99
Nigeria Nigeria 223,000 0% 30
Nicaragua Nicaragua 12,000 0% 97
Netherlands Netherlands 41,000 0% 73
Norway Norway 25,000 +8.7% 84
Nepal Nepal 112,000 0% 51
New Zealand New Zealand 10,000 +11.1% 99
Oman Oman 47,000 0% 68
Pakistan Pakistan 943,000 0% 6
Panama Panama 28,000 0% 81
Peru Peru 158,000 0% 38
Philippines Philippines 157,000 +1.29% 39
Papua New Guinea Papua New Guinea 4,000 0% 105
Poland Poland 189,000 0% 34
North Korea North Korea 1,469,000 0% 3
Portugal Portugal 52,000 0% 65
Paraguay Paraguay 29,000 0% 80
Palestinian Territories Palestinian Territories 0 109
Qatar Qatar 22,000 0% 87
Romania Romania 128,000 +1.59% 47
Russia Russia 1,454,000 0% 4
Rwanda Rwanda 35,000 0% 76
Saudi Arabia Saudi Arabia 282,000 +11.9% 25
Sudan Sudan 144,000 +16.1% 42
Senegal Senegal 19,000 0% 90
Singapore Singapore 59,000 0% 62
Sierra Leone Sierra Leone 9,000 0% 100
El Salvador El Salvador 42,000 0% 72
Somalia Somalia 14,000 -30% 95
Serbia Serbia 32,000 0% 78
South Sudan South Sudan 53,000 -71.4% 64
Suriname Suriname 2,000 0% 107
Slovakia Slovakia 18,000 +12.5% 91
Slovenia Slovenia 7,000 0% 102
Sweden Sweden 15,000 0% 94
Seychelles Seychelles 0 109
Syria Syria 269,000 0% 26
Chad Chad 45,000 0% 70
Togo Togo 10,000 0% 99
Thailand Thailand 455,000 0% 16
Tajikistan Tajikistan 17,000 0% 92
Turkmenistan Turkmenistan 57,000 +35.7% 63
Timor-Leste Timor-Leste 2,000 0% 107
Trinidad & Tobago Trinidad & Tobago 5,000 0% 104
Tunisia Tunisia 48,000 0% 67
Turkey Turkey 512,000 0% 13
Tanzania Tanzania 28,000 0% 81
Uganda Uganda 46,000 0% 69
Ukraine Ukraine 298,000 -4.18% 24
Uruguay Uruguay 22,000 0% 87
United States United States 1,395,000 +0.504% 5
Uzbekistan Uzbekistan 68,000 0% 59
Venezuela Venezuela 343,000 0% 18
Vietnam Vietnam 522,000 0% 12
Yemen Yemen 40,000 0% 74
South Africa South Africa 89,000 -1.11% 53
Zambia Zambia 16,000 0% 93
Zimbabwe Zimbabwe 51,000 0% 66

The indicator 'Armed forces personnel, total' represents the count of active-duty military personnel in a country as of a certain year. This metric serves multiple purposes in assessing a nation's military strength, capability, and readiness. The data for 2020 reveals that there are approximately 27.4 million armed forces personnel worldwide, demonstrating a persistent commitment across nations to national defense and security. The median value of 33,000 personnel indicates a considerable range in military sizes globally, emphasizing both the presence of vast armies in certain nations and the minimal military presence in others.

The significance of this indicator transcends mere statistics. It reflects a country's geopolitical stance, its perceived security threats, and investment in defense. Larger military personnel counts often correlate with nations that have significant territorial disputes or have historically engaged in military conflicts. For instance, the top five countries with the largest armed forces personnel in 2020 include India (3,068,000), China (2,535,000), North Korea (1,469,000), Russia (1,454,000), and the United States (1,395,000). Such figures mirror the respective security concerns and military budgets of these nations, as they maintain a robust military presence to safeguard national interests.

In contrast, several territories report negligible or zero armed forces personnel, such as Antigua & Barbuda, Iceland, Libya, Seychelles, and the Palestinian Territories. These countries may either rely heavily on alliances for their defense or may have different security dynamics that allow for reduced military sizes. The absence of large military forces in these regions can illustrate a lack of perceived threats or an active reliance on international military cooperation and treaties.

The historical data reflects fluctuations in global armed forces personnel numbers from 1985 to 2020. For example, the data indicates spikes in personnel in the late 1990s and the early 2000s, with numbers peaking significantly. This trend might correlate with global military restructuring post-Cold War or reactions to new conflicts emerging in various regions. Observing a slight decline after 2000 suggests a potential shift in military strategies towards technology and more sophisticated warfare methods, prioritizing equipment and strategy over personnel numbers.

Several factors influence the count of armed forces personnel. Political decisions, economic conditions, and social factors play crucial roles. Governments may choose to increase military size in times of perceived threats or decreased when conflict levels diminish or peace treaties are established. Moreover, economic stability directly influences military funding, and thus personnel levels; countries with robust economies can afford to recruit, train, and sustain larger military forces. On the other hand, nations facing economic difficulties might opt for downsizing or entirely restructuring their military forces in favor of modernization rather than expansion.

Strategically, countries may engage in various approaches to manage their armed forces personnel. Some invest heavily in technology and training to enhance the efficiency and effectiveness of a smaller military force. For example, nations like the United States are known for their technological advancements in military equipment, allowing for precision and enhanced capabilities even with a relatively smaller troop count. Others may focus on alliances or engage in international organizations for collective security arrangements, allowing them to maintain lower personnel while relying on partner nations for defense collaboration.

However, there are inherent flaws with solely focusing on the number of armed forces personnel as an indicator of military capability. Quantity does not always equate to quality, as effective military personnel require not only numbers but robust training, morale, and equipment. Additionally, one must consider the political and social ramifications of large militaries, including potential human rights concerns, military overreach, and increased susceptibility to conflict. A large number of personnel may also place an economic burden on a nation, diverting resources from other critical societal needs such as education and healthcare.

In conclusion, the 'Armed forces personnel, total' indicator serves as an essential metric for understanding military composition and national security strategies globally. While it is important to recognize the significance of personnel size in reflecting a nation's military readiness, it is equally crucial to comprehensively analyze the relationship between this indicator and related economic, political, and social factors. By doing so, we gain a holistic perspective on the dynamics influencing national defense and the challenges and opportunities that arise within an ever-evolving global context.

                    
# Install missing packages
import sys
import subprocess

def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# Required packages
for package in ['wbdata', 'country_converter']:
try:
__import__(package)
except ImportError:
install(package)

# Import libraries
import wbdata
import country_converter as coco
from datetime import datetime

# Define World Bank indicator code
dataset_code = 'MS.MIL.TOTL.P1'

# Download data from World Bank API
data = wbdata.get_dataframe({dataset_code: 'value'},
date=(datetime(1960, 1, 1), datetime.today()),
parse_dates=True,
keep_levels=True).reset_index()

# Extract year
data['year'] = data['date'].dt.year

# Convert country names to ISO codes using country_converter
cc = coco.CountryConverter()
data['iso2c'] = cc.convert(names=data['country'], to='ISO2', not_found=None)
data['iso3c'] = cc.convert(names=data['country'], to='ISO3', not_found=None)

# Filter out rows where ISO codes could not be matched — likely not real countries
data = data[data['iso2c'].notna() & data['iso3c'].notna()]

# Sort for calculation
data = data.sort_values(['iso3c', 'year'])

# Calculate YoY absolute and percent change
data['value_change'] = data.groupby('iso3c')['value'].diff()
data['value_change_percent'] = data.groupby('iso3c')['value'].pct_change() * 100

# Calculate ranks (higher GDP per capita = better rank)
data['rank'] = data.groupby('year')['value'].rank(ascending=False, method='dense')

# Calculate rank change from previous year
data['rank_change'] = data.groupby('iso3c')['rank'].diff()

# Select desired columns
final_df = data[['country', 'iso2c', 'iso3c', 'year', 'value',
'value_change', 'value_change_percent', 'rank', 'rank_change']].copy()

# Optional: Add labels as metadata (could be useful for export or UI)
column_labels = {
'country': 'Country name',
'iso2c': 'ISO 2-letter country code',
'iso3c': 'ISO 3-letter country code',
'year': 'Year',
'value': 'GDP per capita (current US$)',
'value_change': 'Year-over-Year change in value',
'value_change_percent': 'Year-over-Year percent change in value',
'rank': 'Country rank by GDP per capita (higher = richer)',
'rank_change': 'Change in rank from previous year'
}

# Display first few rows
print(final_df.head(10))

# Optional: Save to CSV
#final_df.to_csv("gdp_per_capita_cleaned.csv", index=False)
                    
                
                    
# Check and install required packages
required_packages <- c("WDI", "countrycode", "dplyr")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

# Load the necessary libraries
library(WDI)
library(dplyr)
library(countrycode)

# Define the dataset code (World Bank indicator code)
dataset_code <- 'MS.MIL.TOTL.P1'

# Download data using WDI package
dat <- WDI(indicator = dataset_code)

# Filter only countries using 'is_country' from countrycode
# This uses iso2c to identify whether the entry is a recognized country
dat <- dat %>%
  filter(countrycode(iso2c, origin = 'iso2c', destination = 'country.name', warn = FALSE) %in%
           countrycode::codelist$country.name.en)

# Ensure dataset is ordered by country and year
dat <- dat %>%
  arrange(iso3c, year)

# Rename the dataset_code column to "value" for easier manipulation
dat <- dat %>%
  rename(value = !!dataset_code)

# Calculate year-over-year (YoY) change and percentage change
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(
    value_change = value - lag(value),                              # Absolute change from previous year
    value_change_percent = 100 * (value - lag(value)) / lag(value) # Percent change from previous year
  ) %>%
  ungroup()

# Calculate rank by year (higher value => higher rank)
dat <- dat %>%
  group_by(year) %>%
  mutate(rank = dense_rank(desc(value))) %>% # Rank countries by descending value
  ungroup()

# Calculate rank change (positive = moved up, negative = moved down)
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(rank_change = rank - lag(rank)) %>% # Change in rank compared to previous year
  ungroup()

# Select and reorder final columns
final_data <- dat %>%
  select(
    country,
    iso2c,
    iso3c,
    year,
    value,
    value_change,
    value_change_percent,
    rank,
    rank_change
  )

# Add labels (variable descriptions)
attr(final_data$country, "label") <- "Country name"
attr(final_data$iso2c, "label") <- "ISO 2-letter country code"
attr(final_data$iso3c, "label") <- "ISO 3-letter country code"
attr(final_data$year, "label") <- "Year"
attr(final_data$value, "label") <- "GDP per capita (current US$)"
attr(final_data$value_change, "label") <- "Year-over-Year change in value"
attr(final_data$value_change_percent, "label") <- "Year-over-Year percent change in value"
attr(final_data$rank, "label") <- "Country rank by GDP per capita (higher = richer)"
attr(final_data$rank_change, "label") <- "Change in rank from previous year"

# Print the first few rows of the final dataset
print(head(final_data, 10))