Registry / communication / telefonnummer

telefonnummer

JSON →
library2.1.0jsnpmunverified

Telefonnummer is a Swedish phone number formatter and parser (v2.1.0, stable). It formats both mobile and landline numbers to a standardized format with area code support. Includes functions for parsing, validation (with optional mobile-only check), area code lookup, normalization, and equality comparison. Ships TypeScript types. Updated infrequently, last release 2023-09-01. Key differentiator: focused solely on Swedish numbers with official area code data from PTS.

npm install telefonnummer
INSTALL
IMPORT
SIG · TELEFONNUMMER
T
telefonnummer
communicationjavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'telefonnummer'
import parse from 'telefonnummer'
parse is not a default export; it's a named export. Using default import will result in undefined.
validator
import { validator } from 'telefonnummer'
const validator = require('telefonnummer').validator
CJS require works but ESM import is preferred for TypeScript projects.
areaCode
import { areaCode } from 'telefonnummer'
import { areaCodes } from 'telefonnummer'
areaCode is singular, areaCodes is plural and returns an array. Common mistake: confusing these two exports.

Demonstrates parsing Swedish numbers, internationalization option, validation, area code lookup, and numbering area lookup.

import { parse, validator, areaCode, numberingArea } from 'telefonnummer'; // Parse a mobile number const formatted = parse('0701234567'); console.log(formatted); // '070-123 45 67' // Parse with internationalized format const international = parse('0701234567', { internationalized: true }); console.log(international); // '+46701234567' // Validate a landline number const valid = validator('081234567'); console.log(valid); // true // Get area code for a city const code = areaCode('Stockholm'); console.log(code); // '08' // Get numbering area for a code const area = numberingArea('031'); console.log(area); // 'Göteborg'
Debug
Known issues
deprecatedDefault export (parse) may be removed in future versions.
fix
Use named import { parse } instead of default import.
affects: >=1.0.0
gotchaparse() may return 'Röstbrevlåda' (Swedish for 'Voicemail') for numbers like '222' instead of a formatted number.
fix
Check the returned string for unexpected literal values when parsing short numbers.
affects: >=2.0.0
gotchaThe package only handles Swedish phone numbers; international numbers will not be formatted correctly.
fix
Use libphonenumber-js or google-libphonenumber for international numbers.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: parse is not a function
Using default import (import parse from 'telefonnummer') instead of named import.
fix
Use import { parse } from 'telefonnummer'.
Cannot find module 'telefonnummer'
Package not installed or typo in package name.
fix
Run 'npm install telefonnummer' and ensure correct import path.
TypeError: validator is not a function
Trying to call the array areaCodes() as if it's a function validator.
fix
Use import { validator } from 'telefonnummer'.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
telefonnummer — npm install telefonnummer · libregistry