Back to Functions

LENB

Returns the length of a string in bytes." Learn more.

TextLENB(string)

The LENB function in Google Sheets returns the length of a string measured in bytes rather than characters, which matters when working with double-byte character sets like Japanese, Chinese, or Korean text. Dive into our comprehensive guide to see how it differs from the standard LEN function.

Parameters

  • string: The text or cell reference whose byte length you want to measure.

Step-by-Step Tutorial

  1. Measuring the byte length of standard text:

    • Example: =LENB("Hello")
    • Result: 5 (each character is a single byte)
  2. Measuring the byte length of double-byte text:

    • Example: =LENB("こんにちは")
    • Result: 10 (each double-byte character counts as 2 bytes, unlike LEN which would return 5)

Use Cases and Scenarios

  1. Multilingual Data Processing: Accurately measure text length for languages that use double-byte character sets.
  2. Field Length Validation: Enforce byte-based limits required by legacy systems or database fields.
  3. Text Encoding Analysis: Compare LEN and LENB results to detect the presence of double-byte characters in a dataset.

Related Functions

  • LEN: Returns the length of a string in characters.
  • LEFTB: Returns the left portion of a string up to a certain number of bytes.
  • RIGHTB: Returns the right portion of a string up to a certain number of bytes.

Related Articles

Newsletter

More LENB examples coming soon.

We are building short, practical updates for Sheets power users.