Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including phonecc with all npm packages installed. Try it out:

var phonecc = require("phonecc")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

phonecc v2.0.0

A tiny helped to split phone numbers into country codes and phone numbers


A tiny helper to split phone numbers into country codes and phone numbers


Dealing with phone numbers is a pain. And yet its something we deal with on a near daily basis. We created this project to help all those unfortunate folk who have to deal with the tedium of getting country codes and playing with them in phone numbers. Its mostly a WIP but we are trying our best to find time to regularly update and improve the module.


To install the library use

$ npm i phonecc --save

To install the library and save it as a dependency in package.json use

$ npm i phonecc --save

To install the library globally use

$ npm i -g phonecc


var phonecc = require('phonecc')

// Usage with callbacks
phonecc.split(phone, (error, result) => {
    if (error) {
        //TODO: Handle errors here
    } else {
        //TODO: Handle the successful split of numbers
        //Also handle blank cc returns incase no country
        //code existed in the number

// Usage with return value
var result = phonecc.splitSync(phone)
if (result) {
  // Result contains an object of structure {cc: string, phone: string}
} else {
  console.log('error processing phone number')


Hanut Singh Gusain Juggernaut451

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free