Formify Docs

Phone

Format country-aware phone numbers with optional extension

Phone

The phone formatter formats national phone numbers per country and appends an optional extension for extra digits.

Options

OptionDefaultDescription
country"US"US, CA, IN, GB, FR, DE, AU, BR, JP
patterncountry maskCustom mask, e.g. "(###) ###-####"
prefixcountry prefixe.g. "+1 ", "+91 " (empty for some countries)
extfalseAppend an extension when extra digits are typed
extSeparator" ext. "Separator before the extension
extDigits5Max extension digits

Usage

validationSchema: {
  phone: {
    format: { type: "phone", options: { country: "US", ext: true } },
    phone: true,   // validate the formatted value
  },
}

Results

CountryTypedResult
US5551234567(555) 123-4567
US + ext555123456789(555) 123-4567 ext. 89
IN9876543210+91 98765 43210
DE1512345678+49 151 2345678

Things to know

  • Extra digits beyond the country mask only appear when ext: true.
  • Pair with the phone validator for full format validation.

On this page