List of US States in JavaScript object notation

For my future self and the rest of you who may need it at some point in your JavaScript developer life, here is a list of the US States and Territories in JavaScript object notation, sometimes lovingly referred to as JSON.

This is it.  An internet bookmark for JSON states. Really, I just don’t want to go through formatting this again.  I think this was my second time actually…

Enjoy!

This entry was posted in Client Technologies and tagged . Bookmark the permalink.

12 Responses to List of US States in JavaScript object notation

  1. donavon says:

    Depending on what you are looking for, you may want the object keyed off of abbreviation:

    var states = {};
    usStates.forEach(function(s){states[s.abbreviation]=s.name});

  2. Jon says:

    Shouldnt the keys be in quotes to be valid json?

  3. Adam Kinney says:

    Yep, that’s true. I should have mentioned I am just using this as a static array in my project, I’m not passing it through a service.

  4. The all-caps names are making my eyes bleed! :)

    FWIW, a quick google search turns up this (not-all-caps) version :) It seems to be redundant with name and label, though (at least spot-checking a few)

    http://bugs.dojotoolkit.org/attachment/ticket/7273/states.json

  5. Adam Kinney says:

    Hmm, surprised I didn’t find that one. Guess my searching skills were sub par at the time.

    For comparison purposes I wanted either all lowercase or all uppercase, the USPS site had all caps so that’s what I ended up with.

    My main use case here was to be able to find the abbreviation based on the state name.

  6. Thanks for this! By the way, the name for Guam shows up as “GUAM GU”. I think it should just be “GUAM”.

    I created a Gist for two more forms of the states list
    – titlecase form (first letter of every word is uppercase, remaining letters lowercase)
    – dictionary form (using donovan’s suggestion)

    https://gist.github.com/2646763

  7. Adam Kinney says:

    Oh nice, thanks for sharing Michael!

  8. Felix Guerrero says:

    Thank you, I’m using it on my mobile app.

  9. T-Smooth says:

    Thanks for sharing!!!!

  10. Josh says:

    For those looking to work with State JSON data, I creating something similar, but with images of each state. https://github.com/tannerjt/state_images.json

  11. In Eclipse:

    CTRL+SHIFT+Y on a selection of text converts it to lowercase.
    CTRL+SHIFT+X does the opposite to a selection of text.

    [code]
    var states:
    [
    { 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' }
    ]

  12. Though, I should add that Federated States of Micronesia is now an independent nation, Marshall Islands are a part of Micronesia geographically – and its own island country no longer considered US Territory, and Palau is also geographically a part of Micronesia – and its own island country no longer considered US Territory.

Leave a Reply