
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
us-states-normalize
Advanced tools
A library to normalize and convert any variations of US state names and abbreviations.
A library to normalize and convert any variations of US state names and abbreviations.
npm install us-states-normalize --save
var normalize = require('us-states-normalize');
// using original 50 states + D.C.
normalize('Alabama'); // 'AL'
normalize('N.Y.'); // 'NY'
normalize('WashingTON DC'); // 'DC'
normalize('Puerto Rico'); // null - not a state
// to include territories as well such as Guam
normalize('US Virgin Islands', { region: ['state', 'territory'] }); // 'VI'
// to include everything including freely associated states
normalize('Micronesia', { region: 'all' }); // 'FM'
// to return full names
normalize('RI', { returnType: 'name' }); // 'Rhode Island'
// to return customized names
normalize('DC', { // 'Washington DC'
returnType: function(states) {
// states is a key:value store with keys as USPS codes and values as the full names
states['DC'] = 'Washington DC'; // default was { "DC": "District Of Columbia" }
return states;
}
});
// to omit certain states
normalize('DC', { omit: ['DC'] }); // null
The options along with their defaults:
{
region: [String|Array]('state') - ['state', 'territory', 'associated']
returnType: [String|Function]('USPS') - ['USPS', 'AP', 'name', function(states) {}]
omit: [String|Array](null) - list of USPS codes
}
npm test
AL - Alabama
AK - Alaska
AZ - Arizona
AR - Arkansas
CA - California
CO - Colorado
CT - Connecticut
DE - Delaware
DC - District Of Columbia
FL - Florida
GA - Georgia
HI - Hawaii
ID - Idaho
IL - Illinois
IN - Indiana
IA - Iowa
KS - Kansas
KY - Kentucky
LA - Louisiana
ME - Maine
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
OH - Ohio
OK - Oklahoma
OR - Oregon
PA - Pennsylvania
RI - Rhode Island
SC - South Carolina
SD - South Dakota
TN - Tennessee
TX - Texas
UT - Utah
VT - Vermont
VA - Virginia
WA - Washington
WV - West Virginia
WI - Wisconsin
WY - Wyoming
AS - American Samoa
GU - Guam
MP - Northern Mariana Islands
PR - Puerto Rico
VI - Virgin Islands
FM - Federated States Of Micronesia
MH - Marshall Islands
PW - Palau
FAQs
A library to normalize and convert any variations of US state names and abbreviations.
The npm package us-states-normalize receives a total of 887 weekly downloads. As such, us-states-normalize popularity was classified as not popular.
We found that us-states-normalize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.