New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

areacode-to-zipcode

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

areacode-to-zipcode

Translate area codes to zip codes. A utility for looking up postal codes in the US.

latest
Source
npmnpm
Version
1.0.12
Version published
Weekly downloads
75
41.51%
Maintainers
1
Weekly downloads
 
Created
Source

Area Code to Zip Code Lookup

This library provides a simple utility to look up a US ZIP code by area code.

Installation

Clone this repository and install dependencies:

npm install areacode-to-zipcode

Usage

Import the functions and use them in your TypeScript or JavaScript project:

import { getZipcodeFromAreaCode, getDataFromAreaCode } from './lib';

const zip = getZipcodeFromAreaCode(212); // '10024'
console.log(zip);

const data = getDataFromAreaCode(212);
/*
{
  city: "New York City",
  state: "NY",
  zipCode: "10024",
  country: "US"
}
*/
console.log(data);

If the area code is not found, the functions return null.

API

getZipcodeFromAreaCode(areaCode: number): string | null

  • areaCode: The US area code as a number.
  • Returns: The corresponding ZIP code as a string, or null if not found.

getDataFromAreaCode(areaCode: number): { city: string | null, state: string | null, zipCode: string | null, country: string | null } | null

  • areaCode: The US area code as a number.
  • Returns: An object with city, state, zipCode, and country fields, or null if not found.

Testing

Run tests with:

npm test

Data

Area code to ZIP code mappings are stored in lib/data.json.

Keywords

area code

FAQs

Package last updated on 05 Aug 2025

Did you know?

Socket

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.

Install

Related posts