Forms

Make tel: links

normalizeinternational
Link numbers in their international form, and keep domestic-only numbers dialable.
Try it
Try 0120-123-456.

03-5253-8111

How it works

A tel: link in international form works for callers inside and outside Japan.

  • international is the E.164 form, such as +81352538111.
  • Toll-free (0120, 0800) and 0570 numbers cannot be dialed from abroad, so their international is empty. Link them with digits.
  • Show national as the link text.

In each language

import { normalize } from "@kurashina-design/japan-phone";

// A tel: link dials the same number from inside and outside Japan when it is in international form.
// Toll-free and 0570 numbers have no international form, so their link keeps the domestic digits.
function telLink(input) {
  const number = normalize(input);
  if (!number) return null;
  return `<a href="tel:${number.international ?? number.digits}">${number.national}</a>`;
}

for (const input of ["03-5253-8111", "090-1234-5678", "0120-123-456"]) console.log(telLink(input));

Output:

<a href="tel:+81352538111">03-5253-8111</a>
<a href="tel:+819012345678">090-1234-5678</a>
<a href="tel:0120123456">0120-123-456</a>