New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

state-country

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

state-country

Get countries and states from across the world

latest
Source
npmnpm
Version
2.0.7
Version published
Weekly downloads
321
59.7%
Maintainers
1
Weekly downloads
 
Created
Source

state-country

Get a list of all countries, states, or states within a country.

Note: only returns names for countries and states, which makes this a simple and minimal package.

Other popular libraries include city data and extended country/state data (e.g. phone or currency info), which inflates package size by quite a lot. But if you don't need city data and you only need country/state names, this package is a fast, simple, and lightweight alternative.

Installation

 npm i state-country
 or
 yarn add state-country

Usage

 import stateCountry from 'state-country';
 or
 const stateCountry = require('state-country');

Functions

Get all countries in the world

 const countriesList = stateCountry.getAllCountries();

Get all states in the world

 const statesList = stateCountry.getAllStates();

Get all states in a given country

 const statesInCountryList = stateCountry.getAllStatesInCountry('japan');

Search countries

 const searchCountriesList = stateCountry.searchCountries('ja');

Search states

 const searchStatesList = stateCountry.searchStates('north');

Search states in a given country

 const searchStatesInCountryList = stateCountry.searchStatesInCountry('north', 'united states');

Data Source

Country and state data from: https://github.com/dr5hn/countries-states-cities-database. A refresh.js script is included to easily update the countries and states json files with the latest data from countries-states-cities-database.

Keywords

states

FAQs

Package last updated on 22 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts