Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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"
}
]
@miguelduenas
Copy link

thanks !!!

@vegesriharsha
Copy link

thanks!

@anghello
Copy link

Thank you!

@ACPK
Copy link

ACPK commented Aug 30, 2020

@pycoach - Texas is listed twice. On a side note, why do states not have spaces in between words (ex: WestVirginia)?

@sanjmgr
Copy link

sanjmgr commented Sep 9, 2020

Thanks for sharing. Really appreciated :p

@Cesar-mlw
Copy link

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

Thanks for the help! Here's a version for Sequelize migrations

@sanjmgr
Copy link

sanjmgr commented Sep 19, 2020

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

Thanks for the help! Here's a version for Sequelize migrations

Great. Thanks man

@noxend
Copy link

noxend commented Oct 16, 2020

🧡

@KokalaBhanusri
Copy link

@KokalaBhanusri Wyoming is missing closing quotation and TX is duplicated.

Corrected it
Thank you

@japhendywijaya
Copy link

thankyou

@justinmerrell
Copy link

9 years later and still helpful!

@seigel
Copy link

seigel commented Dec 17, 2020

thank you

@qoobes
Copy link

qoobes commented Jan 4, 2021

This is so obscurely useful, thank you

@tmchedlishvili
Copy link

Easy to copy for lazy developers: https://usastatescode.com/state-array-json
Contains different kind of formats.

@endorpheus
Copy link

Magnificent! Gratz!

@ronssij
Copy link

ronssij commented Apr 8, 2021

What about timezone on each states? Can't find any on web.

@kevbost
Copy link

kevbost commented Apr 8, 2021

What about timezone on each states? Can't find any on web.

9 years everyone and their mother has submitted their own states object. If you make one with time zones, post it here -- someone is guaranteed to find it useful, even if it's 9 years from now.

@Mujirin
Copy link

Mujirin commented May 21, 2021

Thank you, super!

@WHITEH0ST
Copy link

For Django ChoiceField, Abbreviation version ;)

states = [('Select', 'Select One'),("Ak","AK"),("AL","AL"),("AR","AR"),("AZ","AZ"),("CA","CA"),("CO","CO"),("CT","CT"),("DE","DE"),("FL","FL"),("GA","GA"),("HI","HI"),("IA","IA"),("ID","ID"),("IL","IL"),("IN","IN"),("KS","KS"),("KY","KY"),("LA","LA"),("MA","MA"),("MD","MD"),("ME","ME"),("MI","MI"),("MN","MN"),("MO","MO"),("MS","MS"),("MT","MT"),("NC","NC"),("ND","ND"),("NE","NE"), ("NH","NH"),("NJ","NJ"),("NM","NM"),("NV","NV"),("NY","NY"),("OH","OH"),("OK","OK"),("OR","OR"),("PA","PA"),("RI","RI"),("SC","SC"),("SD","SD"),("TN","TN"),("TX","TX"),("UT","UT"),("VA","VA"),("VT","VT"),("WA","WA"),("WI","WI"),("WV","WV"),("WY","WY"),("AS","AS"),("AA","AA"),("AE","AE"),("AP","AP"),("PW","PW"),("DC","DC"),("VI","VI"),("PR","PR"),("FM","FM"),("MP","MP"),("GU","GU")]

@gift134
Copy link

gift134 commented Oct 13, 2021

THANK YOU VERY MUCH!!!

@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.

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