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 🙏

© 2025 – Pkg Stats / Ryan Hefner

spain-phone

v1.4.4

Published

Spanish phone number validation

Downloads

41

Readme

Build Status Coverage Status

:telephone_receiver: Spanish phone number validation

Installation

// npm
npm i spain-phone

// yarn
yarn add spain-phone

Demo

https://spain-phone-demo.netlify.com

Usage

Note: Replace the x's with numbers

Check if it is a valid phone number

import { isPhone } from 'spain-phone';

isPhone('907 xx xx xx'); //=> true

Check it is a mobile or fixed number

import { isFixed, isMobile } from 'spain-phone';

isFixed('5xx xx xx xx'); //=> true
isFixed('8xx xx xx xx'); //=> true
isFixed('9xx xx xx xx'); //=> true

isMobile('6xx xx xx xx'); //=> true
isMobile('7xx xx xx xx'); //=> true

State by code / number

import { statesByCode, statesByNumber } from 'spain-phone';

statesByCode('956'); // => ['Cádiz', 'Ceuta']
statesByCode('960'); // => ['Valencia']
statesByCode('93'); // => ['Barcelona']

statesByNumber('956 26 26 08'); // => ['Cádiz', 'Ceuta']);
statesByNumber('960 11 11 11'); // => ['Valencia']);
statesByNumber('934 58 78 60'); // => ['Barcelona']);

Others

import { isFreeCall, isLowCost, isHighCost, isOther } from 'spain-phone';

// paid by who receive the call
isFreeCall('900 xx xx xx'); // => true

// paid 50/50 or at national rate
isLowCost('901 xx xx xx'); // => true

// usually used in tv contest, data system lines and services
isHighCost('905 xx xx xx'); // => true
isHighCost('907 xx xx xx'); // => true
isHighCost('803 xx xx xx'); // => true
isHighCost('806 xx xx xx'); // => true
isHighCost('807 xx xx xx'); // => true

// internet access
isOther('908 xx xx xx'); // => true
isOther('909 xx xx xx'); // => true

// radio-searching
isOther('940 xx xx xx'); // => true

Reference

https://es.wikipedia.org/wiki/Anexo:Prefijos_telef%C3%B3nicos_de_Espa%C3%B1a

Related

  • better-dni - The fastest Spanish DNI (NIE / NIF) validation