Home → How to format output of international phone number with JavaScript
How to format output of international phone number with JavaScript
Published: 11/1/2025
Long story short: if you need to format an international phone number with country code, area code brackets and all the spacing, use libphonenumber-js.
Install package with npm i --save libphonenumber-js
Option 1:
const phone = parsePhoneNumberFromString('+14155552671');
console.log(phone.formatInternational()); // "+1 415 555 2671"Option 2:
const phone = parsePhoneNumberFromString('+14155552671');
console.log(`+${phone.countryCallingCode} ${phone.formatNational()}`); // "+1 (415) 555-2671"