Posts on X can contain up to 280 characters. However, not all characters count equallyβemojis, URLs, and certain Unicode ranges have special counting rules.Documentation Index
Fetch the complete documentation index at: https://docs.x.com/llms.txt
Use this file to discover all available pages before exploring further.
Character weights
X uses a weighted character counting system. Most characters count as 1, but some count as 2:| Character type | Weight | Max characters |
|---|---|---|
| Latin, punctuation, common symbols | 1 | 280 |
| Emojis | 2 | 140 emojis |
| CJK (Chinese, Japanese, Korean) | 2 | 140 characters |
| Other Unicode | 2 (default) | Varies |
Emoji counting
All emojis count as 2 characters, regardless of complexity:| Emoji | Display | Character count | Unicode |
|---|---|---|---|
| πΎ | Single emoji | 2 | U+1F47E |
| ππ½ | With skin tone | 2 | π + π½ modifier |
| π¨βπ€ | Combined with ZWJ | 2 | π¨ + ZWJ + π€ |
| π¨βπ©βπ§βπ¦ | Family sequence | 2 | 4 emojis + 3 ZWJs |
URL handling
All URLs are wrapped witht.co shortener and count as 23 characters, regardless of the original length:
This applies to any valid URL detected in post text.
Special cases
| Content | Counting rule |
|---|---|
| @mentions in replies | Auto-populated @mentions at the start of replies donβt count |
| New @mentions | @mentions you add manually count normally |
| Media | Attached media (via official clients) counts as 0 characters |
| Hashtags | Count normally (# + tag text) |
Text encoding
The X API requires UTF-8 encoding. Character length is calculated using Unicode Normalization Form C (NFC). Example withcafΓ©:
| Form | Bytes | Characters |
|---|---|---|
| NFC (composed) | c a f Γ© | 4 |
| NFD (decomposed) | c a f e Μ | 5 |
Implementation
Use the official twitter-text library for accurate character counting:- JavaScript
- Python
Resources
twitter-text library
Official open-source library for text parsing.
Configuration file
Character weight definitions and Unicode ranges.