npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lacspace/phone

v1.0.0

Published

Parse, validate and format international phone numbers — E.164, national and international formats, country detection from the calling code, per-country length rules. Zero-dependency, isomorphic.

Readme

@lacspace/phone

Phone numbers people actually type. Parse any spelling into E.164, national and international formats, detect the country from the calling code (including the shared +1 and +44 codes), drop trunk prefixes, read extensions, and validate lengths and leading digits per country. Zero dependencies beyond @lacspace/country, isomorphic, fully typed.

npm i @lacspace/phone
import { parsePhone, isValidPhone, formatPhone, phoneCountry } from "@lacspace/phone";

parsePhone("+977 980-123-4567");
// { valid: true, country: "NP", callingCode: "977", national: "9801234567", e164: "+9779801234567",
//   international: "+977 980 123 4567", nationalFormat: "0980 123 4567", type: "mobile" }
parsePhone("(202) 456-1111", { defaultCountry: "US" }).e164;   // "+12024561111"
parsePhone("07911 123456", { defaultCountry: "GB" }).type;      // "mobile"
phoneCountry("+1 416 555 0123");                                // "CA"
formatPhone("+442079460958", "national");                       // "02079 460958"
parsePhone("+977 980123456");                                   // { valid: false, reason: "length", country: "NP", … }

API

| Function | Notes | |---|---| | parsePhone(input, { defaultCountry? }) | Accepts +, 00, brackets, dots, dashes, full-width and Arabic/Devanagari digits, ext./x extensions | | isValidPhone(input, defaultCountry?) | Boolean form | | formatPhone(input, "e164" \| "international" \| "national", defaultCountry?) | Returns the input unchanged when it cannot be parsed | | phoneCountry("+…") | Alpha-2, or undefined | | RULED_COUNTRIES | The 80+ countries with specific length / leading-digit / grouping rules; others use the generic E.164 limits |

Failure reasons: empty characters no-country unknown-calling-code length leading-digits. type is mobile, fixed-or-mobile or unknown, based on the leading digits where the country's plan makes that distinction.

What "valid" means

That the number has a possible structure for its country: a known calling code, an allowed length, no trunk prefix after the country code, and leading digits that exist in the plan. It does not mean the number is assigned or reachable. Grouping follows each country's common display; it is not a carrier-grade formatter.

The Lacspace Developer Platform

This package is part of the Lacspace developer platform: 150+ zero-dependency packages, one CLI, real docs. Browse the Global Data Kit or every package at developer.lacspace.com/packages.

Licence

Free under the Lacspace Free Licence v1.0.