LENB Function

Excel Functions › Text

All Excel versions DBCS languages

The Excel LENB function returns the length of a text string in bytes rather than characters. On a system whose default language is a double-byte character set (DBCS) language — Japanese, Chinese, or Korean — each native character counts as 2 bytes, so =LENB("東京") returns 4 while LEN returns 2. Working in English or any other single-byte language? LENB returns the same number as LEN — just use LEN.


Quick answer: to count the bytes in A2:
=LENB(A2) // 東京2026 = 8 bytes on a Japanese locale; LEN says 6
On non-DBCS locales every character is 1 byte and LENB ≡ LEN.

Syntax

=LENB(text)
ArgumentDescription
textRequiredThe string whose byte length you want. Spaces count; so does every invisible character.

Available in: all Excel versions. Byte counting activates only when a DBCS language (Japanese, Chinese Simplified/Traditional, or Korean) is the system default language. On other locales LENB counts each character as 1 byte — identical to LEN.

LENB vs LEN: counting bytes

Three strings, two counters. Latin text scores the same both ways; kanji double up under LENB on a Japanese-locale machine:

ABC
1Text=LEN(A2)=LENB(A2) on Japanese locale
2Excel55
3東京24
4東京202668
=LENB(A2) // bytes, not characters

The classic real-world use is byte-limit validation. Legacy systems and database columns cap fields in bytes — a 20-byte name field fits 20 Latin letters but only 10 kanji. Flag the overruns before the export bounces:

=IF(LENB(A2) > 20, "too long for export", "ok") // validate against a byte-sized field

And LENB minus LEN counts the double-byte characters directly — each one adds exactly 1 to the difference:

=LENB(A2) - LEN(A2) // how many DBCS characters does A2 contain?

Try it: char vs byte counter

Live demo

Type text (mix in some kanji or kana) and toggle the system locale to watch LEN and LENB agree — then disagree.

Errors & common pitfalls

Pitfall: the same workbook counts differently on different machines. LENB consults the system default language, not the file. A validation column that reads 8 in Tokyo reads 6 in Dallas — and a byte-limit check silently stops checking anything. If a workbook must travel, state the locale assumption next to the formula.

Working in English? Use LEN. On single-byte locales LENB is LEN. LEN is clearer and behaves identically everywhere.

Pitfall: LENB is not UTF-8 byte length. LENB models legacy DBCS encodings: 2 bytes per East Asian character. In UTF-8, kanji take 3 bytes and emoji take 4 — so LENB will not predict the size of a UTF-8 file or API payload. It matches Shift-JIS-era field specs, nothing newer.

Pitfall: blaming the wrong function for count mismatches. If LEN and LENB differ on text you thought was plain ASCII, the text isn’t plain — full-width digits or letters from an Asian-system import are hiding in it. ASC normalises them, and the counts converge.

Practice workbook

📊
Download the free LENB practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

What's the difference between LENB and LEN?
LEN counts characters; LENB counts bytes. On a DBCS system locale (Japanese, Chinese, Korean) each East Asian character counts as 2 bytes, so 東京 scores LEN 2 but LENB 4. On any other locale the two functions return the same number.
Why does LENB return the same number as LEN on my machine?
Your system default language isn’t Japanese, Chinese, or Korean, so Excel counts every character as one byte. That’s by design — and it means you can simply use LEN.
How do I count how many double-byte characters a cell contains?
=LENB(A2) - LEN(A2). Each DBCS character contributes 2 to LENB but 1 to LEN, so the difference is exactly the number of double-byte characters. A result of 0 means the text is entirely single-byte.
Does LENB tell me the UTF-8 size of my text?
No. LENB uses the legacy DBCS model — 2 bytes per East Asian character — while UTF-8 encodes kanji as 3 bytes and emoji as 4. LENB is for validating against old fixed-width and database field specs, not for modern encodings.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: LEN · LEFTB · MIDB · ASC · FINDB