Skip to content

Instantly share code, notes, and snippets.

@mshafrir
Created May 9, 2012 17:05
Show Gist options
  • Save mshafrir/2646763 to your computer and use it in GitHub Desktop.
Save mshafrir/2646763 to your computer and use it in GitHub Desktop.
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
"DC": "District Of Columbia",
"FM": "Federated States Of Micronesia",
"FL": "Florida",
"GA": "Georgia",
"GU": "Guam",
"HI": "Hawaii",
"ID": "Idaho",
"IL": "Illinois",
"IN": "Indiana",
"IA": "Iowa",
"KS": "Kansas",
"KY": "Kentucky",
"LA": "Louisiana",
"ME": "Maine",
"MH": "Marshall Islands",
"MD": "Maryland",
"MA": "Massachusetts",
"MI": "Michigan",
"MN": "Minnesota",
"MS": "Mississippi",
"MO": "Missouri",
"MT": "Montana",
"NE": "Nebraska",
"NV": "Nevada",
"NH": "New Hampshire",
"NJ": "New Jersey",
"NM": "New Mexico",
"NY": "New York",
"NC": "North Carolina",
"ND": "North Dakota",
"MP": "Northern Mariana Islands",
"OH": "Ohio",
"OK": "Oklahoma",
"OR": "Oregon",
"PW": "Palau",
"PA": "Pennsylvania",
"PR": "Puerto Rico",
"RI": "Rhode Island",
"SC": "South Carolina",
"SD": "South Dakota",
"TN": "Tennessee",
"TX": "Texas",
"UT": "Utah",
"VT": "Vermont",
"VI": "Virgin Islands",
"VA": "Virginia",
"WA": "Washington",
"WV": "West Virginia",
"WI": "Wisconsin",
"WY": "Wyoming"
}
[
{
"name": "Alabama",
"abbreviation": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK"
},
{
"name": "American Samoa",
"abbreviation": "AS"
},
{
"name": "Arizona",
"abbreviation": "AZ"
},
{
"name": "Arkansas",
"abbreviation": "AR"
},
{
"name": "California",
"abbreviation": "CA"
},
{
"name": "Colorado",
"abbreviation": "CO"
},
{
"name": "Connecticut",
"abbreviation": "CT"
},
{
"name": "Delaware",
"abbreviation": "DE"
},
{
"name": "District Of Columbia",
"abbreviation": "DC"
},
{
"name": "Federated States Of Micronesia",
"abbreviation": "FM"
},
{
"name": "Florida",
"abbreviation": "FL"
},
{
"name": "Georgia",
"abbreviation": "GA"
},
{
"name": "Guam",
"abbreviation": "GU"
},
{
"name": "Hawaii",
"abbreviation": "HI"
},
{
"name": "Idaho",
"abbreviation": "ID"
},
{
"name": "Illinois",
"abbreviation": "IL"
},
{
"name": "Indiana",
"abbreviation": "IN"
},
{
"name": "Iowa",
"abbreviation": "IA"
},
{
"name": "Kansas",
"abbreviation": "KS"
},
{
"name": "Kentucky",
"abbreviation": "KY"
},
{
"name": "Louisiana",
"abbreviation": "LA"
},
{
"name": "Maine",
"abbreviation": "ME"
},
{
"name": "Marshall Islands",
"abbreviation": "MH"
},
{
"name": "Maryland",
"abbreviation": "MD"
},
{
"name": "Massachusetts",
"abbreviation": "MA"
},
{
"name": "Michigan",
"abbreviation": "MI"
},
{
"name": "Minnesota",
"abbreviation": "MN"
},
{
"name": "Mississippi",
"abbreviation": "MS"
},
{
"name": "Missouri",
"abbreviation": "MO"
},
{
"name": "Montana",
"abbreviation": "MT"
},
{
"name": "Nebraska",
"abbreviation": "NE"
},
{
"name": "Nevada",
"abbreviation": "NV"
},
{
"name": "New Hampshire",
"abbreviation": "NH"
},
{
"name": "New Jersey",
"abbreviation": "NJ"
},
{
"name": "New Mexico",
"abbreviation": "NM"
},
{
"name": "New York",
"abbreviation": "NY"
},
{
"name": "North Carolina",
"abbreviation": "NC"
},
{
"name": "North Dakota",
"abbreviation": "ND"
},
{
"name": "Northern Mariana Islands",
"abbreviation": "MP"
},
{
"name": "Ohio",
"abbreviation": "OH"
},
{
"name": "Oklahoma",
"abbreviation": "OK"
},
{
"name": "Oregon",
"abbreviation": "OR"
},
{
"name": "Palau",
"abbreviation": "PW"
},
{
"name": "Pennsylvania",
"abbreviation": "PA"
},
{
"name": "Puerto Rico",
"abbreviation": "PR"
},
{
"name": "Rhode Island",
"abbreviation": "RI"
},
{
"name": "South Carolina",
"abbreviation": "SC"
},
{
"name": "South Dakota",
"abbreviation": "SD"
},
{
"name": "Tennessee",
"abbreviation": "TN"
},
{
"name": "Texas",
"abbreviation": "TX"
},
{
"name": "Utah",
"abbreviation": "UT"
},
{
"name": "Vermont",
"abbreviation": "VT"
},
{
"name": "Virgin Islands",
"abbreviation": "VI"
},
{
"name": "Virginia",
"abbreviation": "VA"
},
{
"name": "Washington",
"abbreviation": "WA"
},
{
"name": "West Virginia",
"abbreviation": "WV"
},
{
"name": "Wisconsin",
"abbreviation": "WI"
},
{
"name": "Wyoming",
"abbreviation": "WY"
}
]
@sant123
Copy link

sant123 commented Nov 3, 2021

Thank you so much !!!! <3

@avizuber
Copy link

avizuber commented Mar 21, 2022

Here is a version for react-select using full state names:

export const states = [
  { label: "Alaska", value: "Alaska" },
  { label: "Alabama", value: "Alabama" },
  { label: "Arkansas", value: "Arkansas" },
  { label: "Arizona", value: "Arizona" },
  { label: "California", value: "California" },
  { label: "Colorado", value: "Colorado" },
  { label: "Connecticut", value: "Connecticut" },
  { label: "District of Columbia", value: "District of Columbia" },
  { label: "Delaware", value: "Delaware" },
  { label: "Florida", value: "Florida" },
  { label: "Georgia", value: "Georgia" },
  { label: "Hawaii", value: "Hawaii" },
  { label: "Iowa", value: "Iowa" },
  { label: "Idaho", value: "Idaho" },
  { label: "IL", value: "Illinois" },
  { label: "Illinois", value: "Indiana" },
  { label: "Kansas", value: "Kansas" },
  { label: "Kentucky", value: "Kentucky" },
  { label: "Louisiana", value: "Louisiana" },
  { label: "Massachusetts", value: "Massachusetts" },
  { label: "Maryland", value: "Maryland" },
  { label: "Maine", value: "Maine" },
  { label: "Michigan", value: "Michigan" },
  { label: "Minnesota", value: "Minnesota" },
  { label: "Missouri", value: "Missouri" },
  { label: "Mississippi", value: "Mississippi" },
  { label: "Montana", value: "Montana" },
  { label: "North Carolina", value: "North Carolina" },
  { label: "North Dakota", value: "North Dakota" },
  { label: "Nebraska", value: "Nebraska" },
  { label: "New Hampshire", value: "New Hampshire" },
  { label: "New Jersey", value: "New Jersey" },
  { label: "New Mexico", value: "New Mexico" },
  { label: "Nevada", value: "Nevada" },
  { label: "New York", value: "NewYork" },
  { label: "Ohio", value: "Ohio" },
  { label: "Oklahoma", value: "Oklahoma" },
  { label: "Oregon", value: "Oregon" },
  { label: "Pennsylvania", value: "Pennsylvania" },
  { label: "Rhode Island", value: "Rhode Island" },
  { label: "South Carolina", value: "South Carolina" },
  { label: "South Dakota", value: "South Dakota" },
  { label: "Tennessee", value: "Tennessee" },
  { label: "Texas", value: "Texas" },
  { label: "Utah", value: "Utah" },
  { label: "Virginia", value: "Virginia" },
  { label: "Vermont", value: "Vermont" },
  { label: "Washington", value: "Washington" },
  { label: "Wisconsin", value: "Wisconsin" },
  { label: "West Virginia", value: "West Virginia" },
  { label: "Wyoming", value: "Wyoming" },
];

@avizuber
Copy link

If you need typescript constant to read values into dropdown:
const states = [
{ value: 'AK', name: 'Alaska'},
{ value: 'TX', name: 'Texas'},
{ value: 'AL', name: 'Alabama'},
{ value: 'AR', name: 'Arkansas'},
{ value: 'AZ', name: 'Arizona'},
{ value: 'CA', name: 'California'},
{ value: 'CO', name: 'Colorado'},
{ value: 'CT', name: 'Connecticut'},
{ value: 'DC', name: 'DistrictofColumbia'},
{ value: 'DE', name: 'Delaware'},
{ value: 'FL', name: 'Florida'},
{ value: 'GA', name: 'Georgia'},
{ value: 'HI', name: 'Hawaii'},
{ value: 'IA', name: 'Iowa'},
{ value: 'ID', name: 'Idaho'},
{ value: 'IL', name: 'Illinois'},
{ value: 'IN', name: 'Indiana'},
{ value: 'KS', name: 'Kansas'},
{ value: 'KY', name: 'Kentucky'},
{ value: 'LA', name: 'Louisiana'},
{ value: 'MA', name: 'Massachusetts'},
{ value: 'MD', name: 'Maryland'},
{ value: 'ME', name: 'Maine'},
{ value: 'MI', name: 'Michigan'},
{ value: 'MN', name: 'Minnesota'},
{ value: 'MO', name: 'Missouri'},
{ value: 'MS', name: 'Mississippi'},
{ value: 'MT', name: 'Montana'},
{ value: 'NC', name: 'NorthCarolina'},
{ value: 'ND', name: 'NorthDakota'},
{ value: 'NE', name: 'Nebraska'},
{ value: 'NH', name: 'NewHampshire'},
{ value: 'NJ', name: 'NewJersey'},
{ value: 'NM', name: 'NewMexico'},
{ value: 'NV', name: 'Nevada'},
{ value: 'NY', name: 'NewYork'},
{ value: 'OH', name: 'Ohio'},
{ value: 'OK', name: 'Oklahoma'},
{ value: 'OR', name: 'Oregon'},
{ value: 'PA', name: 'Pennsylvania'},
{ value: 'RI', name: 'RhodeIsland'},
{ value: 'SC', name: 'SouthCarolina'},
{ value: 'SD', name: 'SouthDakota'},
{ value: 'TN', name: 'Tennessee'},
{ value: 'TX', name: 'Texas'},
{ value: 'UT', name: 'Utah'},
{ value: 'VA', name: 'Virginia'},
{ value: 'VT', name: 'Vermont'},
{ value: 'WA', name: 'Washington'},
{ value: 'WI', name: 'Wisconsin'},
{ value: 'WV', name: 'WestVirginia'},
{ value: 'WY', name: 'Wyoming'}
];

this has Texas twice, I think ;)

@levarberry
Copy link

Some states have two zones. And one state (AZ) switches timezones.

@jeremyblong
Copy link

This comment will probably be lost in the digital abyss butttttt I've used these snippets MANY times so this time I felt compelled to say thank you for making/providing these - saves a decent chunk of time for sure! The fact that you even thought to post this for others to use and speed up development shows character (thinking of others) sooooo much appreciated and you're a LEGEND!

@nmaldonado-melonheads
Copy link

thank you guys, keep it coming...

@sh0ber
Copy link

sh0ber commented Oct 21, 2022

I needed the reverse

{
"Alabama": "AL",
"Alaska": "AK",
"American Samoa": "AS",
"Arizona": "AZ",
"Arkansas": "AR",
"California": "CA",
"Colorado": "CO",
"Connecticut": "CT",
"Delaware": "DE",
"District Of Columbia": "DC",
"Federated States Of Micronesia": "FM",
"Florida": "FL",
"Georgia": "GA",
"Guam": "GU",
"Hawaii": "HI",
"Idaho": "ID",
"Illinois": "IL",
"Indiana": "IN",
"Iowa": "IA",
"Kansas": "KS",
"Kentucky": "KY",
"Louisiana": "LA",
"Maine": "ME",
"Marshall Islands": "MH",
"Maryland": "MD",
"Massachusetts": "MA",
"Michigan": "MI",
"Minnesota": "MN",
"Mississippi": "MS",
"Missouri": "MO",
"Montana": "MT",
"Nebraska": "NE",
"Nevada": "NV",
"New Hampshire": "NH",
"New Jersey": "NJ",
"New Mexico": "NM",
"New York": "NY",
"North Carolina": "NC",
"North Dakota": "ND",
"Northern Mariana Islands": "MP",
"Ohio": "OH",
"Oklahoma": "OK",
"Oregon": "OR",
"Palau": "PW",
"Pennsylvania": "PA",
"Puerto Rico": "PR",
"Rhode Island": "RI",
"South Carolina": "SC",
"South Dakota": "SD",
"Tennessee": "TN",
"Texas": "TX",
"Utah": "UT",
"Vermont": "VT",
"Virgin Islands": "VI",
"Virginia": "VA",
"Washington": "WA",
"West Virginia": "WV",
"Wisconsin": "WI",
"Wyoming": "WY"
}

@abarke
Copy link

abarke commented Nov 18, 2022

I needed the reverse

{ "Alabama": "AL", "Alaska": "AK", "American Samoa": "AS", "Arizona": "AZ", "Arkansas": "AR", "California": "CA", "Colorado": "CO", "Connecticut": "CT", "Delaware": "DE", "District Of Columbia": "DC", "Federated States Of Micronesia": "FM", "Florida": "FL", "Georgia": "GA", "Guam": "GU", "Hawaii": "HI", "Idaho": "ID", "Illinois": "IL", "Indiana": "IN", "Iowa": "IA", "Kansas": "KS", "Kentucky": "KY", "Louisiana": "LA", "Maine": "ME", "Marshall Islands": "MH", "Maryland": "MD", "Massachusetts": "MA", "Michigan": "MI", "Minnesota": "MN", "Mississippi": "MS", "Missouri": "MO", "Montana": "MT", "Nebraska": "NE", "Nevada": "NV", "New Hampshire": "NH", "New Jersey": "NJ", "New Mexico": "NM", "New York": "NY", "North Carolina": "NC", "North Dakota": "ND", "Northern Mariana Islands": "MP", "Ohio": "OH", "Oklahoma": "OK", "Oregon": "OR", "Palau": "PW", "Pennsylvania": "PA", "Puerto Rico": "PR", "Rhode Island": "RI", "South Carolina": "SC", "South Dakota": "SD", "Tennessee": "TN", "Texas": "TX", "Utah": "UT", "Vermont": "VT", "Virgin Islands": "VI", "Virginia": "VA", "Washington": "WA", "West Virginia": "WV", "Wisconsin": "WI", "Wyoming": "WY" }

You can use:

function swap(json){
  var ret = {};
  for(var key in json){
    ret[json[key]] = key;
  }
  return ret;
}

@baharalidurrani
Copy link

Just in case someone needs a sorted enumeration:

export enum EState {
  /** Alaska */
  AK = 'AK',
  /** Alabama */
  AL = 'AL',
  /** Arkansas */
  AR = 'AR',
  /** American Samoa */
  AS = 'AS',
  /** Arizona */
  AZ = 'AZ',
  /** California */
  CA = 'CA',
  /** Colorado */
  CO = 'CO',
  /** Connecticut */
  CT = 'CT',
  /** District Of Columbia */
  DC = 'DC',
  /** Delaware */
  DE = 'DE',
  /** Florida */
  FL = 'FL',
  /** Federated States Of Micronesia */
  FM = 'FM',
  /** Georgia */
  GA = 'GA',
  /** Guam */
  GU = 'GU',
  /** Hawaii */
  HI = 'HI',
  /** Iowa */
  IA = 'IA',
  /** Idaho */
  ID = 'ID',
  /** Illinois */
  IL = 'IL',
  /** Indiana */
  IN = 'IN',
  /** Kansas */
  KS = 'KS',
  /** Kentucky */
  KY = 'KY',
  /** Louisiana */
  LA = 'LA',
  /** Massachusetts */
  MA = 'MA',
  /** Maryland */
  MD = 'MD',
  /** Maine */
  ME = 'ME',
  /** Marshall Islands */
  MH = 'MH',
  /** Michigan */
  MI = 'MI',
  /** Minnesota */
  MN = 'MN',
  /** Missouri */
  MO = 'MO',
  /** Northern Mariana Islands */
  MP = 'MP',
  /** Mississippi */
  MS = 'MS',
  /** Montana */
  MT = 'MT',
  /** North Carolina */
  NC = 'NC',
  /** North Dakota */
  ND = 'ND',
  /** Nebraska */
  NE = 'NE',
  /** New Hampshire */
  NH = 'NH',
  /** New Jersey */
  NJ = 'NJ',
  /** New Mexico */
  NM = 'NM',
  /** Nevada */
  NV = 'NV',
  /** New York */
  NY = 'NY',
  /** Ohio */
  OH = 'OH',
  /** Oklahoma */
  OK = 'OK',
  /** Oregon */
  OR = 'OR',
  /** Pennsylvania */
  PA = 'PA',
  /** Puerto Rico */
  PR = 'PR',
  /** Palau */
  PW = 'PW',
  /** Rhode Island */
  RI = 'RI',
  /** South Carolina */
  SC = 'SC',
  /** South Dakota */
  SD = 'SD',
  /** Tennessee */
  TN = 'TN',
  /** Texas */
  TX = 'TX',
  /** Utah */
  UT = 'UT',
  /** Virginia */
  VA = 'VA',
  /** Virgin Islands */
  VI = 'VI',
  /** Vermont */
  VT = 'VT',
  /** Washington */
  WA = 'WA',
  /** Wisconsin */
  WI = 'WI',
  /** West Virginia */
  WV = 'WV',
  /** Wyoming */
  WY = 'WY',
}

@Qasim-bbits
Copy link

Can anyone add time zones as well with states?

@ACPK
Copy link

ACPK commented Jan 5, 2023 via email

@Qasim-bbits
Copy link

What is your use case as 13 states have multiple time zones?On Jan 5, 2023, at 6:20 AM, Qasim-bbits @.> wrote:Re: @. commented on this gist.Can anyone add time zones as well with states?—Reply to this email directly, view it on GitHub or unsubscribe.You are receiving this email because you commented on the thread.Triage notifications on the go with GitHub Mobile for iOS or Android.

There are 52 states and 6 time zones in US. One user is creating an event according to his time zone and other users can see that according to their time zones so I need to get user time zones according to his state.

@MountainJay
Copy link

I’m afraid ACPK is correct, timezones are quite a bit more complicated than you’re making it out to be.

If you take a peek into the IANA TZ database, you’ll see many, many timezones in play in the US alone. Not all of them are currently relevant (eg Indiana).

A breakdown of timezones by region worldwide can be seen here: http://efele.net/maps/tz/world/

Arizona, for instance, does not follow DST but the Navajo land inside of it does.

This also ignores the fact that many states have been trying to permanently set themselves to DST. This is much more likely to change in the near future than the US adding a new state, so caching such information in the same file could be problematic.

@zach-betz-hln
Copy link

zach-betz-hln commented Jan 10, 2023

Thank you for this @mshafrir

@Blackjacx
Copy link

Is this somewhere existing for the whole world?!

@Emmanuelhd
Copy link

Is this somewhere existing for the whole world?!

Yes, here.

@nanasnumber
Copy link

Looking for exactly this! Thank you @mshafrir

@evild70
Copy link

evild70 commented Sep 14, 2023

All lowercase. Spaces replaced with dashes.

{
  "al": "alabama",
  "ak": "alaska",
  "as": "american-samoa",
  "az": "arizona",
  "ar": "arkansas",
  "ca": "california",
  "co": "colorado",
  "ct": "connecticut",
  "de": "delaware",
  "dc": "district-of-columbia",
  "fm": "federated-states-of-micronesia",
  "fl": "florida",
  "ga": "georgia",
  "gu": "guam",
  "hi": "hawaii",
  "id": "idaho",
  "il": "illinois",
  "in": "indiana",
  "ia": "iowa",
  "ks": "kansas",
  "ky": "kentucky",
  "la": "louisiana",
  "me": "maine",
  "mh": "marshall-islands",
  "md": "maryland",
  "ma": "massachusetts",
  "mi": "michigan",
  "mn": "minnesota",
  "ms": "mississippi",
  "mo": "missouri",
  "mt": "montana",
  "ne": "nebraska",
  "nv": "nevada",
  "nh": "new-hampshire",
  "nj": "new-jersey",
  "nm": "new-mexico",
  "ny": "new-york",
  "nc": "north-carolina",
  "nd": "north-dakota",
  "mp": "northern-mariana-islands",
  "oh": "ohio",
  "ok": "oklahoma",
  "or": "oregon",
  "pw": "palau",
  "pa": "pennsylvania",
  "pr": "puerto-rico",
  "ri": "rhode-island",
  "sc": "south-carolina",
  "sd": "south-dakota",
  "tn": "tennessee",
  "tx": "texas",
  "ut": "utah",
  "vt": "vermont",
  "vi": "virgin-islands",
  "va": "virginia",
  "wa": "washington",
  "wv": "west-virginia",
  "wi": "wisconsin",
  "wy": "wyoming"
}

@kilonzi
Copy link

kilonzi commented Oct 14, 2023

inspired by @WHITEH0ST to include full names for Django Choicefield: -

US_STATES = (
    ('Select one', 'Select one'), 
    ('AL', 'Alabama'),
    ('AK', 'Alaska'),
    ('AZ', 'Arizona'),
    ('AR', 'Arkansas'),
    ('AS', 'American Samoa'),
    ('CA', 'California'),
    ('CO', 'Colorado'),
    ('CT', 'Connecticut'),
    ('DE', 'Delaware'),
    ('DC', 'District Of Columbia'),
    ('FM', 'Federated States Of Micronesia'),
    ('FL', 'Florida'),
    ('GA', 'Georgia'),
    ('GU', 'Guam'),
    ('HI', 'Hawaii'),
    ('ID', 'Idaho'),
    ('IL', 'Illinois'),
    ('IN', 'Indiana'),
    ('IA', 'Iowa'),
    ('KS', 'Kansas'),
    ('KY', 'Kentucky'),
    ('LA', 'Louisiana'),
    ('ME', 'Maine'),
    ('MH', 'Marshall Islands'),
    ('MD', 'Maryland'),
    ('MA', 'Massachusetts'),
    ('MI', 'Michigan'),
    ('MN', 'Minnesota'),
    ('MS', 'Mississippi'),
    ('MO', 'Missouri'),
    ('MT', 'Montana'),
    ('NE', 'Nebraska'),
    ('NV', 'Nevada'),
    ('NH', 'New Hampshire'),
    ('NJ', 'New Jersey'),
    ('NM', 'New Mexico'),
    ('NY', 'New York'),
    ('NC', 'North Carolina'),
    ('ND', 'North Dakota'),
    ('MP', 'Northern Mariana Islands'),
    ('OH', 'Ohio'),
    ('OK', 'Oklahoma'),
    ('OR', 'Oregon'),
    ('PW', 'Palau'),
    ('PA', 'Pennsylvania'),
    ('PR', 'Puerto Rico'),
    ('RI', 'Rhode Island'),
    ('SC', 'South Carolina'),
    ('SD', 'South Dakota'),
    ('TN', 'Tennessee'),
    ('TX', 'Texas'),
    ('UT', 'Utah'),
    ('VT', 'Vermont'),
    ('VI', 'Virgin Islands'),
    ('VA', 'Virginia'),
    ('WA', 'Washington'),
    ('WV', 'West Virginia'),
    ('WI', 'Wisconsin'),
    ('WY', 'Wyoming')
)

@kuzmicheff
Copy link

Thank you very much for sharing!

@HamzaFa61
Copy link

Thank you for sharing! Do anyone have an idea where I can find the associated cities list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment