Gathering detailed insights and metrics for country-state-city
Gathering detailed insights and metrics for country-state-city
Gathering detailed insights and metrics for country-state-city
Gathering detailed insights and metrics for country-state-city
country-state-city-nextjs
Get all countrys, states and citys of world
react-country-state-city
A lightweight and easy-to-use React library that provides a comprehensive list of regions or continents, countries, states, cities languages, and country phone codes for creating dynamic and searchable dropdowns. Ideal for building forms and input fields
thente-country-state-city
Forked country-state-city Library for fetching Country, its States and Cities
@ixulabs/country-state-city-library
Library for fetching Country, its States and Cities
Basic library for Country, State and City
npm install country-state-city
Typescript
Module System
Node Version
NPM Version
99.6
Supply Chain
100
Quality
76.2
Maintenance
100
Vulnerability
81.3
License
Reduced Bundle Size
Updated on Aug 20, 2023
Minified JSON files - Country, State, City
Updated on Aug 19, 2023
Data split to improve data fixing and better debugging
Updated on Aug 21, 2022
Tree Shaking support - Release : v3.0.0(Not backward compatible)
Updated on Jun 24, 2021
Release v2.0.0
Updated on Jan 05, 2021
First Major Version Release
Updated on May 28, 2019
TypeScript (99.3%)
JavaScript (0.7%)
Total Downloads
11,476,009
Last Day
18,077
Last Week
115,649
Last Month
497,248
Last Year
4,666,074
GPL-3.0 License
295 Stars
207 Commits
191 Forks
6 Watchers
32 Branches
13 Contributors
Updated on Apr 22, 2025
Minified
Minified + Gzipped
Latest Version
3.2.1
Package Id
country-state-city@3.2.1
Unpacked Size
16.69 MB
Size
4.39 MB
File Count
33
NPM Version
8.5.3
Node Version
14.19.0
Published on
Sep 18, 2023
Cumulative downloads
Total Downloads
Last Day
-20.9%
18,077
Compared to previous day
Last Week
1.7%
115,649
Compared to previous week
Last Month
4.8%
497,248
Compared to previous month
Last Year
47.5%
4,666,074
Compared to previous year
Basic library for Country, State and City
Data Source:
https://github.com/dr5hn/countries-states-cities-database
For any data related issue, you can also raise a Issue here.
npm i country-state-city
city.json
file, which was originally around 25MB in an unminified state, has now been reduced to approximately 8MB through minification.city.json
file has been transformed from an Array of Objects to an Array of Arrays of Strings. Previously, the file contained duplicate property names for each object, resulting in a minified file size of 16MB due to JSON formatting requirements. To further minimize this, the file structure has been converted to an Array of Arrays, astonishingly reducing the size to 8MB.city.ts
file. Importantly, these changes do not affect the functionality of existing code. All existing code will continue to work seamlessly without any breaking changes.v3.1.0
data
folder in the root. Please follow this guidelines.Please follow this guidelines
v3.0.0
(Major Version Release - Not backward compatible)ES6 Module usage
1// Latest version - v3.0.0 with Tree Shaking to reduce bundle size 2import { Country, State, City } from 'country-state-city'; 3console.log(Country.getAllCountries()) 4console.log(State.getAllStates()) 5 6// Import Interfaces` 7import { ICountry, IState, ICity } from 'country-state-city' 8
AMD Module usage
1// Latest version - v3.0.0 2let Country = require('country-state-city').Country; 3let State = require('country-state-city').State; 4 5console.log(Country.getAllCountries()) 6console.log(State.getAllStates()) 7
below v2.2.0 and above v0.1.8
ES6 Module usage
1import csc from 'country-state-city';
AMD Module usage
1let csc = require('country-state-city').default;
It accepts a valid CountryCode
eg: 'AS'
and returns Country Details
type: json | ICountry
1{ 2 "isoCode": "IN", 3 "name": "India", 4 "phonecode": "91", 5 "flag": "🇮🇳", 6 "currency": "INR", 7 "latitude": "20.00000000", 8 "longitude": "77.00000000", 9 "timezones": [ 10 { 11 "zoneName": "Asia\/Kolkata", 12 "gmtOffset": 19800, 13 "gmtOffsetName": "UTC+05:30", 14 "abbreviation": "IST", 15 "tzName": "Indian Standard Time" 16 } 17 ] 18}
It accepts a valid StateCode
eg: 'TG'
CountryCode
eg: 'IN'
and returns State Details
type: json | ICountry
1{ 2 "name": "Telangana", 3 "isoCode": "TG", 4 "countryCode": "IN", 5 "latitude": "18.11243720", 6 "longitude": "79.01929970" 7}
It accepts a valid CountryCode
and returns all States as Array of JSON
type: array of json | IState
1[ 2 { 3 "name": "Delhi", 4 "isoCode": "DL", 5 "countryCode": "IN", 6 "latitude": "28.70405920", 7 "longitude": "77.10249020" 8 } 9] 10
It accepts a valid CountryCode
, StateCode
and returns all Cities as Array of JSON
type: array of json | ICity
1[ 2 { 3 "name": "New Delhi", 4 "countryCode": "IN", 5 "stateCode": "DL", 6 "latitude": "28.63576000", 7 "longitude": "77.22445000" 8 } 9] 10
It accepts a valid CountryCode
and returns all Cities as Array of JSON
type: array of json | ICity
1[ 2 { 3 "name": "New Delhi", 4 "countryCode": "IN", 5 "stateCode": "DL", 6 "latitude": "28.63576000", 7 "longitude": "77.22445000" 8 } 9] 10
It returns all Countries
type: array of json | ICountry
1[ 2 { 3 "isoCode": "IN", 4 "name": "India", 5 "phonecode": "91", 6 "flag": "🇮🇳", 7 "currency": "INR", 8 "latitude": "20.00000000", 9 "longitude": "77.00000000", 10 "timezones": [ 11 { 12 "zoneName": "Asia\/Kolkata", 13 "gmtOffset": 19800, 14 "gmtOffsetName": "UTC+05:30", 15 "abbreviation": "IST", 16 "tzName": "Indian Standard Time" 17 } 18 ] 19 } 20]
It returns all States
type: array of json | IState
1[ 2 { 3 "name": "Delhi", 4 "isoCode": "DL", 5 "countryCode": "IN", 6 "latitude": "28.70405920", 7 "longitude": "77.10249020" 8 9 } 10]
It returns all Cities
type: array of json | ICity
1[ 2 { 3 "name": "Delhi", 4 "isoCode": "DL", 5 "countryCode": "IN", 6 "latitude": "28.70405920", 7 "longitude": "77.10249020" 8 } 9]
@baywet - For mentoring Javascript to Typescript Conversion
@dr5hn - For updated World Data Dictionary
taylorthurlow - For pointing into right direction - Module Tree Shaking
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
Found 2/16 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More