Registry / productivity / phone-format-kr

phone-format-kr

JSON →
library1.0.0jsnpmunverified

Korean phone number formatter and validator. Version 1.0.0 provides formatting, validation, parsing, and type detection for all major Korean phone number formats (mobile, Seoul, regional, representative, toll-free, VoIP). Supports international +82 input, custom delimiters, and middle-digit masking. Ships TypeScript types with a clean, zero-dependency API. No active release cadence; stable initial release.

npm install phone-format-kr
INSTALL
IMPORT
SIG · PHONE-FORMAT-KR
P
phone-format-kr
productivityjavascriptv1.0.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.

formatPhone
import { formatPhone } from 'phone-format-kr'
const formatPhone = require('phone-format-kr').formatPhone
ESM-only; CommonJS require may work with bundlers but is not officially supported.
isValidPhone
import { isValidPhone } from 'phone-format-kr'
import isValidPhone from 'phone-format-kr'
Named export, not default.
getPhoneType
import { getPhoneType } from 'phone-format-kr'
Returns a PhoneType string literal, not an enum.
parsePhone
import { parsePhone } from 'phone-format-kr'
Returns { type: string, parts: string[] } or null.

Demonstrates formatting, validation, type detection, parsing, and options for Korean phone numbers.

import { formatPhone, isValidPhone, getPhoneType, parsePhone } from 'phone-format-kr'; // Format a mobile number const formatted = formatPhone('01012345678'); console.log(formatted); // "010-1234-5678" // Validate a phone number const valid = isValidPhone('01012345678'); console.log(valid); // true // Get phone type const type = getPhoneType('01012345678'); console.log(type); // "mobile" // Parse into components const parsed = parsePhone('0212345678'); console.log(parsed); // { type: 'seoul', parts: ['02', '1234', '5678'] } // Custom delimiter and masking const masked = formatPhone('01012345678', { delimiter: '.', mask: true }); console.log(masked); // "010.****.5678"
Debug
Known issues
gotchaInput must be a numeric string without country code prefix (except +82 which is stripped). Letters or mixed characters cause null return for formatPhone and false for isValidPhone.
fix
Sanitize input to digits only before calling functions.
affects: >=1.0.0
gotchaformatPhone returns null for invalid inputs; not always a string. Ensure to handle null case.
fix
Use optional chaining or null check: const result = formatPhone(...) ?? '';
affects: >=1.0.0
gotchaInternational format support is limited to +82 prefix. Other country codes like +1 are not handled and return null.
fix
Only pass Korean numbers starting with 0 or +82.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0 , phone_format_kr.formatPhone) is not a function
Using default import instead of named import.
fix
Use named import: import { formatPhone } from 'phone-format-kr'
Cannot read properties of null (reading 'toString')
formatPhone returns null for invalid input, but code assumes string.
fix
Check return value: const result = formatPhone(...); if (result !== null) { ... }
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
phone-format-kr — npm install phone-format-kr · libregistry