Text function

LENB function

Counts the bytes in a text string: 2 for each double-byte (CJK) character when a DBCS language is the default, otherwise the same as LEN.

Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web

In every Excel versionWorks in Google Sheets

Syntax

LENB(text)
ArgumentWhat it means
textRequiredThe text or cell to measure.

Returns: A whole number of bytes.

How LENB works

LENB measures text in bytes rather than characters. In the double-byte character sets used for Japanese, Chinese and Korean, Latin letters, digits and half-width katakana take 1 byte while kanji, hanzi, hangul, kana and full-width symbols take 2. Many legacy systems (bank transfer files, invoice printers, government forms) limit fields by bytes, so a 20-byte name field holds only 10 kanji. LENB tells you whether a value fits.

Byte counting only happens when a double-byte (DBCS) language - Japanese, Chinese (Simplified or Traditional) or Korean - is set as the default editing language under File > Options > Language. With any other default language every character counts as 1 byte and the B version behaves exactly like the normal one.

A neat trick follows from this: with a DBCS default language, LENB(A2)-LEN(A2) is the number of double-byte characters in the cell, which lets you detect full-width characters that should have been typed half-width.

Examples

1Byte length of a Japanese name (Japanese default language)

B2fx=LENB(A2)
AB
1Name
2東京タワー10

Result: 10

Five full-width characters at 2 bytes each make 10 bytes; LEN(A2) returns 5.

2Mixed text (Japanese default language)

B2fx=LENB(A2)
AB
1Product
2Excel東京9

Result: 9

Excel is 5 single-byte characters, 東京 adds 4 bytes: 9 in total, while LEN gives 7.

3Count double-byte characters (Japanese default language)

B2fx=LENB(A2)-LEN(A2)
AB
1Phone (typed)
203-1234-56784

Result: 4

The four digits 1234 were typed in full-width. Each adds one extra byte, so the difference is 4 - a sign the value needs ASC.

4English default language

B2fx=LENB(A2)
AB
1Name
2東京タワー5

Result: 5

Without a DBCS default language every character is counted as 1 byte, so LENB equals LEN.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 16 KB

Tips

  • Check field limits with =IF(LENB(A2)>20,"Too long","OK") before exporting to byte-limited systems.
  • LENB does not report UTF-8 sizes; it follows the legacy double-byte model. A kanji takes 3 bytes in UTF-8 but LENB counts 2.

Google Sheets

LENB also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

LENB in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
PolishDŁ.B
RussianДЛИНБ
SpanishLARGOB