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.
On this page ⌄
"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:
| Measure | Value |
|---|---|
string.length in JavaScript (UTF-16 code units) | 11 |
Code points ([...s].length) | 7 |
Grapheme clusters (Intl.Segmenter), what a person sees | 1 |
| UTF-8 bytes | 25 |
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):
| Text | UTF-16 | Code points | Graphemes | UTF-8 | X weight |
|---|---|---|---|---|---|
é as one code point (NFC) | 1 | 1 | 1 | 2 | 1 |
é as e + combining accent (NFD) | 2 | 2 | 1 | 3 | 1 |
| 😀 | 2 | 1 | 1 | 4 | 2 |
| 🇩🇪 (flag, two regional indicators) | 4 | 2 | 1 | 8 | 2 |
| 👍🏽 (thumbs up + skin tone) | 4 | 2 | 1 | 8 | 2 |
| 👨👩👧 (3 people) | 8 | 5 | 1 | 18 | 2 |
| 你好 | 2 | 2 | 2 | 6 | 4 |
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.
| Text | UTF-16 | Code points | Graphemes | UTF-8 |
|---|---|---|---|---|
| 🏳️🌈 (white flag, variation selector, joiner, rainbow) | 6 | 4 | 1 | 14 |
| ❤️ (U+2764 plus U+FE0F) | 2 | 2 | 1 | 6 |
| क्षि (Devanagari, four code points) | 4 | 4 | 1 | 12 |
| CRLF line break | 2 | 2 | 1 | 2 |
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
| Where | Limit | What is counted | Source, read 2026-11-02 |
|---|---|---|---|
| X post | 280 | weighted: Latin characters 1, CJK 2, every emoji 2, every URL 23, counted after NFC normalization | X developer docs, "Counting characters"; also tested |
| SMS, GSM-7 | 160 per single message | 7-bit alphabet; extended characters such as { and ] count as two | Twilio GSM-7 glossary |
| SMS, concatenated | 153 per part (GSM-7) | 134 octets per part after a 6-octet header | Wikipedia "Concatenated SMS" |
| SMS, UCS-2 | 70 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 read | derived |
| YouTube Data API | title 100 characters; description 5,000 bytes; tags 500 characters in total | the description limit is in bytes, and commas and quote marks around tags with spaces count | YouTube Data API videos resource |
| Google title and snippet | no limit; truncated "typically to fit the device width" | not characters | Google Search Central: title links, snippets |
| PostgreSQL identifier | 63 bytes | bytes, longer names are truncated | PostgreSQL docs; tested |
PostgreSQL varchar(n) | n characters | code points | tested |
MySQL VARCHAR(n) | n characters; 65,535 bytes per row for all columns | at most 4 bytes per character in utf8mb4, so about 16,383 characters in one column | MySQL 8.4 manual; not run |
| Node.js HTTP headers | 16,384 bytes total (default) | bytes | http.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.
| Limit | Unit stated by the source | How many family emojis fit (derived) | Source |
|---|---|---|---|
| X post, 280 | weighted: Latin 1, CJK 2, "Emoji sequences with skin tones or zero-width joiners" 2, every URL 23 | 140 | X developer docs, counting characters |
Bluesky post text, maxGraphemes 300 and maxLength 3000 | graphemes and UTF-8 bytes; a post must satisfy both | 120 (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 units | 200 (2,200 divided by 11) | TikTok Content Posting API reference |
YouTube Data API, snippet.description 5000 | bytes | 200 (5,000 divided by 25) | YouTube Data API, videos resource |
HTML maxlength on an input | the 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 default | characters; every link counts as 23, and a mention counts only its username, not the domain | not stated | Mastodon 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
Word Counter
Count words, characters, sentences, paragraphs, and lines. Reading time estimate, char-limit indicators for X, LinkedIn, meta titles, and more.
Hours Calculator
Add start, end and break times for each day to see daily hours, weekly totals and overtime instantly.
Character Counter
Count characters, words, sentences, lines and UTF-8 bytes with live SEO and social media limit tracking.
Keyboard Test
Press any key to see it light up and find dead, stuck or double-typing keys, with rollover checks for full size, TKL and 75% layouts.
Written by Mian Ali Khalid. More guides in Dev Productivity.