Karu Tools

Text

Byte Counter (UTF-8) and Character Counter

Count UTF-8 bytes, Unicode code points, visible characters, and JavaScript string length for any text, with options for line endings, a BOM, and whitespace.

Totals

UTF-8 bytes

0bytes

Visible characters
0
Code points
0
JavaScript string length
0
Lines
0lines

Input is limited to 100,000 characters.

Counting options

The text box always stores LF. Switch here to see the size a CRLF file would have.

A UTF-8 BOM adds 3 bytes. It is excluded by default.

Counting methods compared

The same text gives different totals depending on how and what you count.

UTF-8 bytes

Size when stored or sent

As entered0
Without line breaks0
Without whitespace0

UTF-16 bytes

2 bytes per code unit

As entered0
Without line breaks0
Without whitespace0

Visible characters

Grapheme clusters

As entered0
Without line breaks0
Without whitespace0

Code points

Unicode scalar positions

As entered0
Without line breaks0
Without whitespace0

JavaScript string length

string.length

As entered0
Without line breaks0
Without whitespace0

Characters by UTF-8 length

Counted per code point. Japanese characters take 3 bytes and most emoji take 4.

1 byte
0
2 bytes
0
3 bytes
0
4 bytes
0

Count UTF-8 bytes, not just characters

Paste any text to see its UTF-8 size next to the visible character count, the Unicode code point count, and the JavaScript string length. Use it when a limit is measured in bytes rather than characters: database column widths, API payload caps, cookie and header sizes, or file size estimates.

For writing volume, use the character counter instead. To measure what an encoding step costs, paste the output of the Base64 converter or theURL encoder back into this tool. Everything is counted in your browser, and nothing is stored or uploaded.

Open detailed notes

How many bytes is one character in UTF-8?

UTF-8 is variable length. ASCII letters, digits, and punctuation take 1 byte; accented Latin, Greek, and Cyrillic letters take 2; Japanese, Chinese, and Korean characters take 3; most emoji and rarer CJK characters take 4. Ten characters can therefore be anywhere from 10 to 40 bytes.

Why character counts disagree

There are three common answers to "how long is this string": visible characters (grapheme clusters), Unicode code points, and UTF-16 code units, which is what JavaScript's string.length returns. The emoji 😀 is 1 visible character, 1 code point, a string length of 2, and 4 UTF-8 bytes. All three are shown together so you can tell which one your limit is actually counting.

Emoji and combining marks

Emoji joined with a zero-width joiner, such as family or profession emoji, and flag emoji built from regional indicator pairs, stay one visible character while their bytes add up part by part. The same applies to a base letter plus a combining accent: one visible character, two code points. Visible characters are counted as grapheme clusters using Intl.Segmenter.

Line endings and the BOM

A line break is 1 byte as LF and 2 bytes as CRLF. Browsers always store LF in a text box, so switch the line-ending option when you are estimating the size of a Windows file. A UTF-8 BOM is 3 bytes. It is excluded by default, and a BOM already at the start of the input is removed before counting so it is never counted twice.

What each counting scope excludes

  • As entered: the text exactly as typed, using the selected line ending.
  • Without line breaks: line breaks removed, which matches sending the text as a single line.
  • Without whitespace: spaces, full-width spaces, tabs, and line breaks removed. A BOM is not treated as whitespace.

Frequently asked questions

Is the text I enter saved?

No. Counting runs only in your browser, and the text is not sent to a server.

How is this different from the character counter?

This tool focuses on data size and on how counting methods disagree. Use the character counter when you need paragraph counts or manuscript-page estimates for writing.

How are emoji counted?

A typical emoji is 4 UTF-8 bytes, 1 code point, 2 JavaScript string units, and 1 visible character. Emoji built from several joined code points, such as family or flag emoji, stay one visible character but add up the bytes of every part.

Are line breaks included in the byte count?

Yes. LF counts as 1 byte and CRLF counts as 2 bytes. The text box always stores LF, so switch the line-ending option to see the size a Windows CRLF file would have.

Is the BOM counted?

Not by default. A BOM at the start of the input is removed before counting, and the BOM option adds the 3 UTF-8 bytes back when you need that figure.

Can it count Shift_JIS or EUC-JP bytes?

No. It counts UTF-8 and UTF-16 only. Japanese text in Shift_JIS is usually 2 bytes per character and will not match the UTF-8 result.