Twitter/X 280 Character Limit: How Characters Are Counted
Understand how Twitter counts characters for the 280-character limit, including special handling of URLs, emoji, and CJK characters.
Detailed Explanation
Twitter's Character Counting Rules
Twitter's 280-character limit does not simply use JavaScript's .length. Twitter uses its own weighted counting system based on Unicode ranges, and URLs have special handling.
Twitter's Counting Rules
| Character Type | Weight |
|---|---|
| ASCII (U+0000–U+10FF) | 1 |
| Most other characters | 1 |
| CJK characters (U+2E80–U+9FFF, etc.) | 2 |
| CJK symbols and punctuation | 2 |
| Emoji | varies (usually 2) |
| URLs | 23 (fixed, regardless of actual length) |
Examples
"Hello World" (11 ASCII chars)
Twitter count: 11
JS .length: 11
"こんにちは" (5 Japanese chars)
Twitter count: 10 (5 × 2)
JS .length: 5
"Check https://example.com/very-long-url" (40 chars)
Twitter count: 29 (6 + 23 for URL)
JS .length: 40
Why This Matters for Developers
If you are building a Twitter client or post scheduler:
- Do not use
.lengthfor the character counter - Use Twitter's text parsing library (
twitter-text) for accurate counting - Count CJK as double to avoid posts being rejected
- URLs always count as 23 regardless of length, because Twitter wraps them in t.co
Emoji Counting
Most emoji count as 2 characters on Twitter, regardless of their code point complexity:
"😀" (simple emoji) Twitter: 2, .length: 2
"👨👩👧" (family emoji) Twitter: 2, .length: 8
"🇯🇵" (flag emoji) Twitter: 2, .length: 4
This means complex emoji sequences are actually "cheaper" on Twitter relative to their byte size.
Maximizing Character Usage
To fit the most content in a tweet:
- Use ASCII where possible (1 character each)
- Long URLs are fine (always 23 characters)
- Emoji are relatively efficient (2 characters for often complex meaning)
- CJK text uses characters at 2x rate
Use Case
When building social media management tools, post schedulers, or Twitter API integrations, implementing accurate character counting according to Twitter's weighted scheme prevents post rejection and allows users to maximize their content within the 280-character limit.