Xerobit
Dev Productivity

JavaScript String Length of Emoji and Which Limits Count What

Why one emoji has a JavaScript length of 11, and which limits count UTF-16 units, bytes or graphemes: X, Bluesky, TikTok, YouTube, SMS, Postgres, HTTP headers.

MA Mian Ali Khalid Updated Nov 19, 2026 8 min read
Free tool
Word Counter
Count words, characters, sentences, paragraphs, and lines. Reading time estimate, char-limit indicators for X, LinkedIn, meta titles, and more.
Open tool →
On this page ⌄
  1. One emoji, five lengths
  2. Counting correctly in JavaScript
  3. Sourced limits
  4. Which unit each limit counts
  5. Search snippets: Google has no character limit
  6. Database pitfalls
  7. HTTP header size
  8. Limits not covered
  9. Tested

"Character" has at least four meanings, and every limit uses one of them: the family emoji below is 11 in JavaScript, 7 in Python and Postgres, 25 in a UTF-8 byte count and 1 on screen. This page lists limits confirmed in the vendor's own documentation or by running them (X, YouTube, Google Search and the HTML specification were re-read on 2026-11-19, the rest on 2026-11-02), and says which unit each one counts. Limits that could not be confirmed in a primary source are named at the end rather than guessed.

One emoji, five lengths

The family emoji 👨‍👩‍👧‍👦 is four people joined by three zero-width joiners. Measured in Node 25.8 and PostgreSQL, with the Xerobit word counter's own counting code and the official twitter-text library:

MeasureValue
string.length in JavaScript (UTF-16 code units)11
Code points ([...s].length)7
Grapheme clusters (Intl.Segmenter), what a person sees1
UTF-8 bytes25
X post weight (twitter-text 3.1.0)2
PostgreSQL length() / octet_length()7 / 25

More examples from the same run (columns: UTF-16 units, code points, graphemes, UTF-8 bytes, X weight):

TextUTF-16Code pointsGraphemesUTF-8X weight
é as one code point (NFC)11121
é as e + combining accent (NFD)22131
😀21142
🇩🇪 (flag, two regional indicators)42182
👍🏽 (thumbs up + skin tone)42182
👨‍👩‍👧 (3 people)851182
你好22264

The 3-person family has 8 UTF-16 units and 18 bytes; the 4-person one in the first table has 11 and 25.

Four more strings, counted again on 2026-11-19 with Node v26.13.1 (ICU 78.3, Unicode 17.0) and Python 3.11.15. Python's len() returned the same figure as the code-point column in every row, and its UTF-16 and UTF-8 byte counts matched Node's.

TextUTF-16Code pointsGraphemesUTF-8
🏳️‍🌈 (white flag, variation selector, joiner, rainbow)64114
❤️ (U+2764 plus U+FE0F)2216
क्षि (Devanagari, four code points)44112
CRLF line break2212

A grapheme cluster is the unit Unicode defines for what a reader perceives as one character; UAX #29, Unicode Text Segmentation (revision 49 for Unicode 18.0.0, dated 2026-09-01) calls extended grapheme clusters the default and names them "user-perceived characters". The line break row shows why a line count and a character count can differ by one: a Windows newline is two code points but one grapheme.

Counting correctly in JavaScript

const s = '👨‍👩‍👧‍👦';
s.length;                                                         // 11
[...s].length;                                                    // 7
[...new Intl.Segmenter('en', { granularity: 'grapheme' }).segment(s)].length;   // 1
new TextEncoder().encode(s).length;                               // 25

The common bug is cutting a string at a fixed length. '👨‍👩'.slice(0, 1) gave a lone surrogate "\ud83d". Cut at grapheme boundaries instead: taking the first two graphemes of a👨‍👩‍👧b with the segmenter returned a👨‍👩‍👧. On the string Hi + the 4-person family + 🇩🇪 + !, text.slice(0, 8) returned Hi 👨‍👩, which turned a four-person family into a two-person couple without any error, and taking the first 4 graphemes returned Hi 👨‍👩‍👧‍👦 (14 UTF-16 units). Segmentation depends on the runtime's Unicode data, so a very new emoji may split on an older engine.

One consequence for tools: the Word Counter reports "Characters" as text.length, which is UTF-16 code units, so the family emoji shows 11 characters and 25 bytes there. It is the right number for JavaScript string limits, and not the number a person would count.

Sourced limits

WhereLimitWhat is countedSource, read 2026-11-02
X post280weighted: Latin characters 1, CJK 2, every emoji 2, every URL 23, counted after NFC normalizationX developer docs, "Counting characters"; also tested
SMS, GSM-7160 per single message7-bit alphabet; extended characters such as { and ] count as twoTwilio GSM-7 glossary
SMS, concatenated153 per part (GSM-7)134 octets per part after a 6-octet headerWikipedia "Concatenated SMS"
SMS, UCS-270 single, 67 per part (derived)16 bits per character; the numbers follow from the 140-octet message and the 6-octet header, and are not stated in the documentation readderived
YouTube Data APItitle 100 characters; description 5,000 bytes; tags 500 characters in totalthe description limit is in bytes, and commas and quote marks around tags with spaces countYouTube Data API videos resource
Google title and snippetno limit; truncated "typically to fit the device width"not charactersGoogle Search Central: title links, snippets
PostgreSQL identifier63 bytesbytes, longer names are truncatedPostgreSQL docs; tested
PostgreSQL varchar(n)n characterscode pointstested
MySQL VARCHAR(n)n characters; 65,535 bytes per row for all columnsat most 4 bytes per character in utf8mb4, so about 16,383 characters in one columnMySQL 8.4 manual; not run
Node.js HTTP headers16,384 bytes total (default)byteshttp.maxHeaderSize; tested

The X numbers match the library: twitter-text returned a weighted length of 23 for a long URL, 2 for the 4-person family and 4 for 你好, accepted 280 as and rejected 281, and accepted 140 CJK characters and rejected 141. A decomposed "café" and a composed one both weighed 4.

SMS note: a message with one character outside the GSM-7 alphabet is sent as UCS-2, so one emoji drops the single-message size from 160 to 70 (Twilio says devices switch encodings but does not give the trigger on the page read; the 160 to 70 drop follows from the encodings above).

Which unit each limit counts

The same text hits different limits depending on the unit. The table lists limits whose unit the platform's own documentation states, read on 2026-11-19, with the 4-person family emoji as the test string.

LimitUnit stated by the sourceHow many family emojis fit (derived)Source
X post, 280weighted: Latin 1, CJK 2, "Emoji sequences with skin tones or zero-width joiners" 2, every URL 23140X developer docs, counting characters
Bluesky post text, maxGraphemes 300 and maxLength 3000graphemes and UTF-8 bytes; a post must satisfy both120 (3,000 bytes divided by 25)atproto app.bsky.feed.post lexicon and the Lexicon specification
TikTok Content Posting API, video caption 2200"UTF-16 runes", which are UTF-16 code units200 (2,200 divided by 11)TikTok Content Posting API reference
YouTube Data API, snippet.description 5000bytes200 (5,000 divided by 25)YouTube Data API, videos resource
HTML maxlength on an inputthe Infra "length", "the number of code units it contains"9 (100 divided by 11, rounded down, for maxlength="100")HTML Standard, Infra Standard
Mastodon post, 500 by defaultcharacters; every link counts as 23, and a mention counts only its username, not the domainnot statedMastodon documentation, posting

Counts for the 4-person family on 120, 121, 200 and 201 copies, run in Node: 120 copies = 120 graphemes, 1,320 UTF-16 units, 3,000 UTF-8 bytes; 121 copies = 121 graphemes, 1,331 units, 3,025 bytes; 200 copies = 2,200 units and 5,000 bytes; 201 copies = 2,211 units and 5,025 bytes. Those rows are where the Bluesky, TikTok and YouTube thresholds land: the 121st family passes the 300-grapheme limit but breaks the 3,000-byte one.

The documents do not always agree with each other. YouTube's API reference gives the description limit as 5,000 bytes, while the YouTube Help page says "a character limit of 5,000 characters" for the same field. For plain English they are the same number; for text with accents, CJK or emoji they are not, so count bytes when you send descriptions through the API. The HTML specification text that was read says only that the number of characters is "measured using length", which points to the Infra definition above; this was not run in a browser, so check your target browser if the input matters.

Search snippets: Google has no character limit

The widely quoted "60 characters for a title and 155 to 160 for a description" are rules of thumb, not Google rules. Google's documentation says "there's no limit on how long a <title> element can be" and no limit on a meta description, only that the result is truncated "typically to fit the device width". Both pages were re-read on 2026-11-19: title links and snippets. Snippets come "primarily" from page content, and the meta description is used when it describes the page better. To control snippet length, Google points to the max-snippet meta tag. Aim for titles that fit a typical result width, but do not treat 60 as a threshold.

Database pitfalls

PostgreSQL counts characters in varchar(n). With varchar(5): five 😀 (5 characters, 20 bytes) went in; café plus three 😀 (7 characters) failed with value too long for type character varying(5); so did the family emoji, which is 7 code points even though it is one grapheme.

PostgreSQL identifiers are limited by bytes, not characters. A 70-character table name was accepted with the notice identifier ... will be truncated to 63 characters, and a name of 40 é (80 bytes) was truncated to 31 characters (62 bytes), since the 32nd would have crossed the 63-byte line. Two long names that share a prefix can silently collide.

MySQL also counts VARCHAR(n) in characters, but the row-size limit is in bytes, so a wide utf8mb4 column can exceed it. Not run: MySQL. The MySQL manual's own example shows that VARCHAR keeps trailing spaces while CHAR strips them on retrieval.

HTTP header size

Node's default maximum for all request headers together is 16,384 bytes (http.maxHeaderSize). Test requests with a single header of 8 kB and of 15 kB returned 200 OK, 17 kB returned 431, and 100 kB had the connection reset. Proxies, CDNs and other servers each have their own limits that were not tested.

Limits not covered

Instagram captions and bios, LinkedIn posts and the in-app TikTok caption are not listed. On 2026-11-19 no official Instagram help page with a limit turned up in search, the LinkedIn help URL that was tried did not contain a post limit, and TikTok's documented figure is for its API only. Many third-party guides quote 2,200 characters for Instagram and 3,000 for LinkedIn, and they may be right, but a number that cannot be traced to the platform stays out of the tables. Platforms change these often; check the composer or the platform's current help page.

Tested

2026-11-19: Node v26.13.1 (ICU 78.3, Unicode 17.0) and Python 3.11.15 for the extra strings, the truncation example and the repetition counts. The X, YouTube (API and Help), Google Search title and snippet, HTML, Infra, UAX #29, Mastodon, atproto lexicon (read through the GitHub API at commit 627b309) and TikTok pages were read the same day. The "how many fit" counts are arithmetic on those limits, not posts made to the platforms.

2026-11-02: Node v25.8.0 (Intl.Segmenter, http), twitter-text 3.1.0, PostgreSQL 18.6, the Xerobit word counter module run in Node. Official pages read the same day as listed in the table.

Keep reading

Related tools

Written by Mian Ali Khalid. More guides in Dev Productivity.