A safe phone-number formatting workflow
1. Accept
Use a telephone input and allow ordinary spaces, parentheses and hyphens. Do not require users to understand E.164 before they can type.
2. Preserve
Keep the original submitted value for support and audit purposes. Never overwrite it with an inferred country or silently corrected number.
3. Resolve context
Ask for a country when national-format input is allowed. A local number without a country code is not globally self-identifying.
4. Normalize
Convert Unicode digits and plus signs, remove display punctuation, separate any extension, and reject unsupported symbols.
5. Parse and validate
Split the calling code from the national significant number, then apply the selected country’s reviewed length and trunk-prefix rules.
6. Store and explain
Write a canonical +digits field only after parsing succeeds. Return structured warnings and retain a human-readable display value separately.
What should a web form collect?
The HTML telephone input is the appropriate control, but the HTML Standard intentionally does not impose one telephone-number grammar because valid formats vary widely. Use the control for device-friendly input, then apply your own country-aware validation and accessible error messages.
<label>
Country
<select name="country" autocomplete="country-code">...</select>
</label>
<label>
Phone number
<input type="tel" name="phone" autocomplete="tel" inputmode="tel">
</label>
<label>
Extension (optional)
<input type="text" name="phone_extension" inputmode="numeric">
</label>Before-and-after conversion examples
X characters are safe placeholders, not dialable subscriber digits.
| Case | Input | Required context | Canonical field | Transformation |
|---|---|---|---|---|
| UK landline | 020 7946 XXXX | Country = GB | +44207946XXXX | Remove the domestic trunk 0 after +44. |
| Italian landline | 06 XXXXXXXX | Country = IT | +3906XXXXXXXX | Retain the significant geographic 0 after +39. |
| US exit-code input | 011 44 20 7946 XXXX | Origin = US, destination = GB | +44207946XXXX | Remove the origin-specific 011 before storage. |
| Brazil carrier dial string | 0 21 11 9XXXX XXXX | Country = BR | +55119XXXXXXXX | Remove domestic routing and carrier-selection digits. |
| Copied Unicode | +44 20‑7946‑XXXX | Country code present | +44207946XXXX | Normalize full-width characters and display punctuation. |
| PBX extension | +1 202 555 01XX ext. 204 | Global number plus extension | +120255501XX | Store extension 204 in a separate field or RFC 3966 tel URI parameter. |
Format rules by channel
| Context | Preferred representation | Validation boundary |
|---|---|---|
| Web form | Friendly input plus explicit country selection | Validate on submit and again on the server; type=tel does not enforce a global syntax. |
| CRM | Canonical number, raw input, country and extension in separate fields | Keep provenance and last-validated time so later numbering-plan changes can be handled. |
| SMS platform | Canonical international destination accepted by that provider | Formatting does not prove the line is mobile, reachable, opted in or able to receive SMS. |
| Messaging app | Provider-specific international identifier | Check the app’s current API rules; do not assume every valid phone number has an account. |
| Database or API | + followed by country code and national significant number | Use digits-only storage after +; derive localized display formatting at the presentation layer. |
| Clickable link | tel:+44207946XXXX or tel:+120255501XX;ext=204 | RFC 3966 distinguishes the telephone identifier from the dial string used by a particular origin network. |
Common validation failures and useful messages
Too many digits
The country code plus national number exceeds the 15-digit E.164 maximum. Ask the user to remove an extension or duplicated prefix.
Unsupported symbols
Reject letters, multiple plus signs, # or * in the canonical field. Preserve the raw input so the user can correct it.
Exit code included
Explain that 00, 010, 011 or 0011 belongs to the origin dial string, not to the saved destination.
Country code duplicated
Detect values such as +44 44… after country selection and ask which version is intended instead of silently deleting digits.
Country is ambiguous
Require a country selection when the input is national. Browser locale or IP location is a hint, not consent to rewrite a number.
Plausible but unverified
Say that the format is possible; do not label the number active, mobile, owned or opted in without separate evidence.
Test the workflow
Use the browser-only checker for normalization feedback, then review the validation guide before adding carrier, reachability or proof-of-control checks.
Standards and implementation sources
- ITU-T E.164: The international public telecommunication numbering planInternational Telecommunication Union. Verified 2026-07-19.
- ITU-T E.123: Notation for national and international telephone numbersInternational Telecommunication Union. Verified 2026-07-19.
- HTML Standard: Telephone state (type=tel)WHATWG. Verified 2026-08-19.
- RFC 3966: The tel URI for Telephone NumbersRFC Editor. Verified 2026-08-19.
See our editorial and sourcing methodology.