Input rules

What normalize and extract accept, and what they reject on purpose.

Supported numbers

TypeNumbersNotationInternational
fixed_lineArea code + local exchange, 10 digitsFrom the MIC tables, such as 03-5253-8111 or 04998-2-3111Yes
mobile060, 070, 080, 090, 11 digits090-1234-5678Yes
ip_phone050, 11 digits050-1234-5678Yes
toll_free0120 (10 digits), 0800 (11 digits)0120-123-456, 0800-123-4567No
unified_number0570, 10 digits0570-123-456No

Fixed-line hyphens come from the MIC tables, not from the brackets in the input, so 0922(12)1234 becomes 092-212-1234. Blocks marked unused in the tables are accepted.

Not supported: 020 (data transmission mobile), 0990, short codes such as 110, and numbers from other countries.

normalize

normalize takes one value. It accepts:

  • half-width and full-width digits, and the single-digit kanji 〇一二三四五六七八九;
  • half-width and full-width spaces, hyphens (-, -, ‐, ‑, −), and brackets around the local exchange or the whole number;
  • +81, including the bracketed domestic 0 in +81-(0)50-3818-1250, for fixed-line, mobile, and 050;
  • a leading TEL:, FAX:, 電話:, or 電話番号:, and a trailing (代表), (代), (直通), or extension written with 内線.

It rejects, on purpose:

  • broken separators such as 090--1234-5678 or an unclosed bracket;
  • letters mixed into digits, such as 090-ABCD-5678;
  • line breaks or tabs, more than one number, or other words around the number;
  • values longer than 128 characters;
  • +810… without brackets, and kanji with place values such as 十 or 零;
  • numbers without an area code. japan-phone never guesses one.

extract

extract takes text of any length and returns the numbers it finds, in order.

  • Any text may surround a number, including line breaks.
  • It joins digit groups separated by up to three half-width or full-width spaces, hyphens (including ー and dashes), brackets, or periods.
  • Each candidate is validated as strictly as by normalize. Digit strings that do not fit the numbering plan or the MIC tables are skipped.
  • It never cuts a number out of a longer run of digits. Digits of other scripts, such as Arabic-Indic, count as part of the run (for example, nothing is found in ١09012345678). The digits are fixed to the decimal digits of Unicode 18.0, so they do not change with the Unicode version of the runtime.
  • It ignores where the separators fall. Misgrouped numbers such as 0120-12-3456 or 0922-12-1234 are returned with the correct grouping. As a result, other digit strings of the same length, such as part numbers, are picked up when they happen to fall in a valid block (for example, 0352-538-111 becomes 03-5253-8111).
  • +81 is read for fixed-line, mobile, and 050 numbers, including +81-0-90-1234-5678 with the domestic 0 written as its own group.
  • Digits after a + other than +81, such as +1 or +999, are treated as a foreign number and skipped with the digits joined to them, also with up to three separators between the + and the digits (+ 1, +(1)). +1 090-1234-5678 never yields a Japanese number. As a result, a number after a decorative or arithmetic +, as in 1+1 090-1234-5678 or 基本料金 + 090-1234-5678, is not found either. When four or more characters, or a character that is not a separator, come between the + and the digits (as in + (要予約) 090-1234-5678), the + does not count and the number is found.
  • The same number written twice is returned twice.