body{background:#0f1117;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;line-height:1.8;max-width:800px;margin:0 auto;padding:2rem} h1{color:#fff;font-size:2.2rem;margin-top:2rem} h2{color:#8b5cf6;font-size:1.5rem;margin-top:2.5rem;border-bottom:1px solid #1e1e2e;padding-bottom:.5rem} h3{color:#c4b5fd;font-size:1.2rem;margin-top:1.5rem} p{margin:1rem 0} a{color:#8b5cf6;text-decoration:none} a:hover{text-decoration:underline} code{background:#1e1e2e;padding:2px 6px;border-radius:4px;font-size:.9rem} pre{background:#1e1e2e;padding:1rem;border-radius:8px;overflow-x:auto;margin:1rem 0} details{background:#161822;border:1px solid #2a2d3a;border-radius:8px;margin:1rem 0;padding:1rem} summary{cursor:pointer;color:#8b5cf6;font-weight:600;font-size:1.05rem} details p{margin-top:.8rem} .tip{background:#1a1a2e;border-left:4px solid #8b5cf6;padding:1rem 1.5rem;border-radius:0 8px 8px 0;margin:1.5rem 0} .tip strong{color:#c4b5fd} ul,ol{padding-left:1.5rem} li{margin:.4rem 0} table{width:100%;border-collapse:collapse;margin:1.5rem 0} th,td{border:1px solid #2a2d3a;padding:.6rem;text-align:left} th{background:#1a1a2e;color:#8b5cf6} window.dataLayer=window.dataLayer||[]; function gtag(){dataLayer.push(arguments);} gtag("js",new Date()); gtag("config","G-9J54FYQT11");
Whether you are crafting a tweet that stays under the limit, writing an SEO meta description that gets clicked, or debugging a database field that truncates user input, understanding how text is measured matters more than most people realize. Characters, words, and bytes are three fundamentally different ways of counting text, and confusing them leads to broken layouts, rejected submissions, and poor search rankings. This guide clarifies the differences, provides a comprehensive reference for character limits across platforms, explains how to write effective meta descriptions, and covers string handling essentials for developers.
A character is any single symbol in a piece of text. This includes letters (both uppercase and lowercase), numbers, punctuation marks, spaces, and special symbols. The string "Hello, World!" contains 13 characters: 10 letters, 1 comma, 1 space, and 1 exclamation mark. Most social media platforms and form fields measure their limits in characters. When a tool counts characters, it typically counts every keystroke — including spaces and line breaks.
Words are counted by splitting text at whitespace boundaries. "Hello, World!" is two words. This seems straightforward, but edge cases create ambiguity. Hyphenated terms like "state-of-the-art" may count as one word or four depending on the counter. Numbers separated by spaces ("2024 12 25") count as three words. URLs and email addresses are usually counted as single words despite containing no spaces. Different tools use different splitting algorithms, so word counts can vary slightly between platforms.
A byte is a unit of digital information storage. In text encoding, bytes measure how much storage space a string occupies. The relationship between characters and bytes depends on the encoding scheme:
Knowing the exact limits for each platform saves time and prevents content from being cut off. Here is a current reference for the most popular platforms:
| Platform | Element | Limit |
|---|---|---|
| X (Twitter) | Post | 280 characters |
| X (Twitter) | Display name | 50 characters |
| X (Twitter) | Bio | 160 characters |
| Caption | 2,200 characters | |
| Bio | 150 characters | |
| Hashtags per post | 30 | |
| Alt text | 100 characters | |
| Post | 3,000 characters | |
| Headline | 220 characters | |
| Summary (About) | 2,600 characters | |
| Post | 63,206 characters | |
| Bio | 101 characters | |
| TikTok | Caption | 2,200 characters |
| TikTok | Bio | 80 characters |
| YouTube | Video title | 100 characters |
| YouTube | Video description | 5,000 characters |
| YouTube | Channel description | 1,000 characters |
| YouTube | Tags | 500 characters total |
| Pin description | 500 characters | |
| Board name | 100 characters | |
| Snapchat | Bio | 80 characters |
| Threads | Post | 500 characters |
A meta description is an HTML attribute that provides a brief summary of a webpage's content. Search engines display it as the snippet below the page title in search results. While Google has confirmed that meta descriptions are not a direct ranking factor, they significantly influence click-through rates (CTR). A well-written meta description can be the difference between a user clicking your result or scrolling to a competitor.
Google typically displays up to 155–160 characters of a meta description on desktop and around 120 characters on mobile before truncating with an ellipsis. However, Google measures in pixels rather than characters — the actual cutoff depends on character width. A description filled with wide characters (W, M, uppercase letters) gets cut off sooner than one with narrow characters (i, l, t, spaces). A practical guideline is to aim for 140–155 characters to ensure your full description is visible across devices.
Different programming languages handle string length differently, which is a common source of bugs when working with international text:
# Python — len() returns the number of Unicode code points
len("café") # 4
len("你好") # 2
len("🚀") # 1
# JavaScript — .length also returns code points
"café".length // 4
"你好".length // 2
"🚀".length // 1
# But JavaScript has a trap with surrogate pairs:
"👨👩👧👦".length // 7 (not 1!) — this is a family emoji made of 7 code points
[..."👨👩👧👦"].length // 7
# Python bytes:
len("café".encode("utf-8")) # 5 bytes
len("你好".encode("utf-8")) # 6 bytes
len("🚀".encode("utf-8")) # 4 bytes
# Python
def count_words(text):
return len(text.split())
# JavaScript
function countWords(text) {
return text.trim().split(/\s+/).filter(Boolean).length;
}
Both approaches split on whitespace, which handles most cases. For more accurate counting that respects punctuation (e.g., not counting "state-of-the-art" as four words), you would use regular expressions like \b\w+\b or dedicated NLP libraries.
| Situation | Measure | Why |
|---|---|---|
| Social media posts | Characters | Platforms enforce character limits |
| Blog posts and articles | Words | Readability and content length |
| Database schema design | Bytes | Storage allocation |
| SEO meta descriptions | Characters | Display truncation |
| Email subject lines | Characters | Display cutoff (~60-80 chars) |
| SMS messages | Characters | 160 chars per SMS segment (GSM-7) |
| URL slugs | Characters | Browsers truncate long URLs |
| API rate limits | Characters or tokens | Varies by API |
Yes. Spaces, tabs, line breaks, and all other whitespace characters are counted as individual characters by virtually every character counting tool and social media platform. A string with 10 letters and 9 spaces between them is 19 characters long.
X (Twitter) historically counted each character by its UTF-16 code unit value. Most emoji are encoded as surrogate pairs in UTF-16, which means they occupy 2 code units and count as 2 characters toward the 280-character limit. This is a technical artifact of how JavaScript handles Unicode, not an intentional design choice by Twitter.
A code point is a numeric value assigned to a character in the Unicode standard. Most of the time, one code point equals one visible character. However, some visual characters — like flag emoji, skin-tone modifiers, and ZWJ (zero-width joiner) sequences — are composed of multiple code points that combine into a single visible grapheme. The family emoji 👨👩👧👦 is one visible character but seven code points.
Remove spaces before counting. In JavaScript: text.replace(/\s/g, "").length. In Python: len(text.replace(" ", "")). This is useful for situations where only the visible characters matter, such as counting letters in a word game or calculating character density.
This usually happens for one of three reasons: (1) The platform counts bytes, not characters — common with non-ASCII text in databases. (2) The platform uses pixel-based truncation, where wide characters take up more display space. (3) Hidden characters like zero-width spaces or non-breaking spaces are being counted but not displayed.
Most email clients display 60–80 characters before truncating. Research shows that subject lines between 40 and 50 characters tend to have the highest open rates. Keeping your subject line concise and front-loading the most important information ensures it is readable even on mobile devices with smaller screens.
If your meta description exceeds the display limit, Google truncates it with an ellipsis. However, Google does not always use your meta description at all — it may instead extract a relevant snippet from the page content that better matches the user's search query. Writing a unique, accurate meta description for each page gives you the best chance of controlling what appears in search results.
A standard SMS message using GSM-7 encoding supports 160 characters. If your message contains any character outside the GSM-7 set (such as emoji, accented letters, or certain symbols), the entire message switches to UCS-2 encoding, which reduces the limit to 70 characters per segment. Long messages are split into multiple segments, each counted separately for billing purposes.