Skip to content

String Byte Counter

Measure text in UTF-8 bytes, code points, UTF-16 units and graphemes.

Quick Tool Overview

The String Byte Counter measures a string four ways at once — UTF-8 bytes, code points, UTF-16 units and graphemes — because using the wrong one of those is a real and common source of bugs.

What it does
Measures text in bytes, code points, units and graphemes
You give it
Any string
You get back
All four counts plus a per-size breakdown
Best for
Database column limits, API field limits and key sizes
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the String Byte Counter

Four different numbers can all reasonably be called "the length" of a string, and using the wrong one causes real bugs. This counts all four: UTF-8 bytes, Unicode code points, UTF-16 units — which is what JavaScript's .length returns — and graphemes, which is what a reader calls characters.

The gaps between them are where things break. A VARCHAR(255) counts bytes in some databases and characters in others. A DynamoDB key limit counts bytes. A JavaScript length check counts UTF-16 units, so one emoji counts as two. A Twitter-style limit counts graphemes, so an emoji with a skin tone counts as one despite being four code points. The breakdown shows how many characters take one, two, three and four bytes, so you can see exactly where the size is going.

Key features of the String Byte Counter

Four counts, side by side

UTF-8 bytes, code points, UTF-16 units and graphemes — the four things that all get called "length" and are all different.

Where the bytes go

How many characters take one, two, three and four bytes, so an oversized field has an obvious explanation.

Real grapheme counting

Uses the browser's own segmenter, so an emoji with a skin tone counts as one character rather than four.

Limit checking

Set a byte or character limit and see the headroom, which is the actual question behind most visits.

Live as you type

Every count updates on each keystroke, so trimming a value to fit is immediate.

How to use the String Byte Counter

  1. 1

    Paste your text

    Any string — a field value, a message, a key.

  2. 2

    Read the four counts

    UTF-8 bytes, code points, UTF-16 units and graphemes, side by side.

  3. 3

    Check the byte breakdown

    How many characters take one, two, three or four bytes each.

  4. 4

    Compare against your limit

    Set a byte or character limit and see how much headroom is left.

Frequently asked questions

It depends. MySQL VARCHAR(255) counts characters, but the index key length is in bytes — which is why a utf8mb4 column can exceed an index limit. PostgreSQL varchar counts characters. Check both.

Reviews of the String Byte Counter

What people who use the String Byte Counter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the String Byte Counter. It takes half a minute and no account.

Write the first review

More developer tools