States, Provinces & Administrative Divisions

โ† Back to docs

The states array contains 600+ administrative divisions across 20+ countries: US states, Canadian provinces, Australian states, Swiss cantons, Brazilian states, German Lรคnder, French regions, Spanish autonomous communities, Italian regions, Mexican states, Japanese prefectures, Indian states, Chinese provinces, and more.

Import

import {
  states,
  getStatesByCountry,
  getStateByCode,
  getStatesByType,
} from "arevdata";
import type { State, StateType } from "arevdata";

Data shape

interface State {
  name: string;      // "California"
  code: string;      // "CA" โ€” state/province abbreviation code
  country: string;   // "US" โ€” ISO 3166-1 alpha-2 country code
  type: StateType;   // "state" | "province" | "territory" | ...
}

type StateType =
  | "state"
  | "province"
  | "territory"
  | "autonomous region"
  | "district"
  | "department"
  | "region"
  | "county"
  | "emirate"
  | "canton";

Examples

All divisions for a country

import { getStatesByCountry } from "arevdata";

// United States
const usAll = getStatesByCountry("US");
console.log(usAll.length); // 50 states + DC + territories = 57

// Switzerland
const chAll = getStatesByCountry("CH");
console.log(chAll.length); // 26 cantons

// Japan
const jpAll = getStatesByCountry("JP");
console.log(jpAll.length); // 47 prefectures

Look up a specific division by code

import { getStateByCode } from "arevdata";

getStateByCode("CA", "US");
// { name: "California", code: "CA", country: "US", type: "state" }

getStateByCode("ON", "CA");
// { name: "Ontario", code: "ON", country: "CA", type: "province" }

getStateByCode("ZZ", "US"); // undefined

Filter by division type

import { getStatesByType } from "arevdata";

// All provinces (CA, AU, ...)
const provinces = getStatesByType("province");

// All cantons (Switzerland)
const cantons = getStatesByType("canton");
cantons.every(c => c.country === "CH"); // true
cantons.length; // 26

// All territories
const territories = getStatesByType("territory");
territories.map(t => `${t.name} (${t.country})`);
// ["Australian Capital Territory (AU)", "Northwest Territories (CA)", ...]

Build a state selector that changes with the selected country

import { getStatesByCountry } from "arevdata";

function getStateOptions(countryCode: string) {
  const divisions = getStatesByCountry(countryCode);
  if (divisions.length === 0) return null; // no division data for this country

  return divisions.map(s => ({
    value: s.code,
    label: s.name,
  }));
}

getStateOptions("US");
// [{ value: "AL", label: "Alabama" }, { value: "AK", label: "Alaska" }, ...]

getStateOptions("CH");
// [{ value: "ZH", label: "Zurich" }, { value: "BE", label: "Bern" }, ...]

Country coverage

Country Type Count
๐Ÿ‡บ๐Ÿ‡ธ United States states + DC + territories 57
๐Ÿ‡จ๐Ÿ‡ฆ Canada provinces + territories 13
๐Ÿ‡ฆ๐Ÿ‡บ Australia states + territories 8
๐Ÿ‡ง๐Ÿ‡ท Brazil states + DF 27
๐Ÿ‡ฉ๐Ÿ‡ช Germany Lรคnder 16
๐Ÿ‡ซ๐Ÿ‡ท France regions + overseas 18
๐Ÿ‡ช๐Ÿ‡ธ Spain autonomous communities 17
๐Ÿ‡ฎ๐Ÿ‡น Italy regions 20
๐Ÿ‡ฒ๐Ÿ‡ฝ Mexico states + CDMX 32
๐Ÿ‡ฎ๐Ÿ‡ณ India states + union territories 36
๐Ÿ‡จ๐Ÿ‡ณ China provinces + autonomous regions + municipalities 33
๐Ÿ‡ฏ๐Ÿ‡ต Japan prefectures 47
๐Ÿ‡จ๐Ÿ‡ญ Switzerland cantons 26
๐Ÿ‡ท๐Ÿ‡บ Russia federal subjects (8 major regions + Moscow) 9
๐Ÿ‡ฆ๐Ÿ‡ช UAE emirates 7
๐Ÿ‡ณ๐Ÿ‡ด Norway counties 15
๐Ÿ‡ต๐Ÿ‡น Portugal districts 18
๐Ÿ‡ณ๐Ÿ‡ฑ Netherlands provinces 12
๐Ÿ‡ง๐Ÿ‡ช Belgium provinces 10
๐Ÿ‡ธ๐Ÿ‡ช Sweden counties 21
  • Countries โ€” the country field in each State uses alpha-2 codes from countries
  • Cities โ€” the state field in each City aligns with state names here