String length calculator (characters and bytes)
A string's length depends on what you count: user-visible characters, Unicode code points, UTF-16 code units (what JavaScript's .length reports) or UTF-8 bytes (what storage and byte limits count), while SMS counts its own 7-bit or 16-bit units. Paste text to see all of them side by side.
Characters
11
14 code points · 15 UTF-16 units (.length) · 29 UTF-8 bytes
- Characters you see
- 11grapheme clusters (Intl.Segmenter)
- Characters, excluding spaces
- 9spaces, tabs and line breaks left out
- Unicode code points
- 14[...text].length in JavaScript; len() in Python
- UTF-16 code units
- 15JavaScript's .length
- UTF-8 bytes
- 29a UTF-8 file or utf8mb4 column; len() in Go
- UTF-16 bytes
- 302 per code unit, without a byte order mark
- Words
- 2word boundaries from Intl.Segmenter
- Lines
- 1a line break at the very end doesn't start a new line
- SMS encoding
- UCS-2 (16-bit)“👋”, “न”, “म”, “स”, “्” and more aren't in the GSM 7-bit alphabet
- SMS segments
- 115 of 70 16-bit units
| Character | Times | Code points | UTF-16 units | UTF-8 bytes |
|---|---|---|---|---|
| 👋 | 1 | U+1F44B | 2 | 4 |
| न | 1 | U+0928 | 1 | 3 |
| म | 1 | U+092E | 1 | 3 |
| स्ते | 1 | U+0938 U+094D U+0924 U+0947 | 4 | 12 |
- 11 visible characters are made of 14 code points: an emoji with a skin tone, a flag, or a letter with a combining mark or vowel sign is one character on screen but several code points.
- 1 code point above U+FFFF takes two UTF-16 code units each (a surrogate pair), which is why .length is 15 and not 14.
How is the length of a string counted?
A string has several lengths, depending on the unit. The characters you see are grapheme clusters, defined by Unicode's text segmentation rules (UAX #29) and counted here with the browser's Intl.Segmenter. Underneath, each one is one or more Unicode code points: an accented letter can be one code point or two, and the three-person family emoji is five code points (three people and two zero-width joiners) shown as one picture.
Code points are then stored as code units. JavaScript strings are UTF-16, so .length counts 16-bit units, and a code point above U+FFFF, such as the waving hand emoji U+1F44B, takes two of them, a surrogate pair. UTF-8, the encoding TextEncoder produces and MySQL's utf8mb4 stores, uses 1 to 4 bytes per code point (RFC 3629): 1 for ASCII, 2 for é, 3 for ₹ and for Hindi and Tamil letters, and 4 for anything above U+FFFF.
Words come from the same segmenter's word boundaries, which also work for languages written without spaces; punctuation and emoji don't count as words. Lines are counted from line breaks, with a break at the very end not starting a new line.
SMS uses its own count. 3GPP TS 23.038 says a message in the GSM 7-bit default alphabet can hold up to 160 characters, and one in UCS2 up to 70; a message with even one character outside that alphabet, such as ₹, an emoji or a Hindi letter, needs UCS2 instead. UCS2 stops at U+FFFF, so this page counts a character above it, such as an emoji, as two 16-bit units, the way UTF-16 writes it; check with your SMS provider for those. The extension table characters € [ ] { } \ ^ ~ | each take two of the 160. TS 23.040 sets 153 and 67 per part when a message is split, because each part carries a header for reassembly.
Segmentation follows the Unicode version of the browser. Unicode 15.1 added a rule (GB9c) that keeps Devanagari conjuncts such as स्ते together, so नमस्ते is 3 characters on current systems and 4 with older Unicode data. TS 23.038 also defines national language tables for Hindi, Tamil and other languages, but says locking-shift encoding isn't intended to be used until a national regulator asks for it, so this page counts with the default alphabet.
characters you see → Intl.Segmenter(granularity: "grapheme") code points → [...text].length UTF-16 code units → text.length UTF-8 bytes → new TextEncoder().encode(text).length SMS: GSM 7-bit 160, or 153 per part · UCS-2 70, or 67 per part
How long are emoji, accented letters and Indian scripts?
| Text | Characters you see | Code points | UTF-16 units (.length) | UTF-8 bytes | SMS |
|---|---|---|---|---|---|
| A | 1 | 1 | 1 | 1 | GSM 7-bit, 1 septet |
| é (one code point, U+00E9) | 1 | 1 | 1 | 2 | GSM 7-bit, 1 septet |
| é (e + combining U+0301) | 1 | 2 | 2 | 3 | UCS-2, 2 units |
| ₹ | 1 | 1 | 1 | 3 | UCS-2, 1 unit |
| € | 1 | 1 | 1 | 3 | GSM 7-bit, 2 septets |
| 👋 | 1 | 1 | 2 | 4 | UCS-2, 2 units |
| 👋🏽 (with a skin tone) | 1 | 2 | 4 | 8 | UCS-2, 4 units |
| 👨👩👧 (family, joined) | 1 | 5 | 8 | 18 | UCS-2, 8 units |
| 🇮🇳 (flag) | 1 | 2 | 4 | 8 | UCS-2, 4 units |
| नमस्ते (Hindi) | 3 | 6 | 6 | 18 | UCS-2, 6 units |
| வணக்கம் (Tamil) | 5 | 7 | 7 | 21 | UCS-2, 7 units |
| Hello 👋 नमस्ते | 11 | 14 | 15 | 29 | UCS-2, 15 units |
How to count the characters and bytes in a string
- 1Paste the textType or paste up to 200,000 characters. It is counted in your browser as you type, and nothing is sent anywhere.
- 2Pick the count you needUse the characters you see for a visible limit, code points or UTF-16 units for code, and UTF-8 bytes for storage or an API's byte limit.
- 3Check the SMS costSee whether the text fits the GSM 7-bit alphabet or needs UCS-2, and how many segments it takes.
- 4Find the costly charactersThe table lists every character that isn't plain ASCII with its code points, UTF-16 units and UTF-8 bytes.
Frequently asked questions
Why does JavaScript's .length count one emoji as 2?
Does MySQL VARCHAR(255) count characters or bytes?
How many characters fit in one SMS?
How many bytes does a Hindi or Tamil letter take in UTF-8?
Why can two strings that look identical have different lengths?
Sources
- Unicode Standard Annex #29, Unicode Text Segmentation (grapheme clusters, word boundaries) (checked 20 Oct 2026)
- UAX #29 revision 43 for Unicode 15.1 (rule GB9c for Indic conjuncts; absent from the Unicode 15.0 revision) (checked 20 Oct 2026)
- MDN, Intl.Segmenter() constructor (grapheme and word granularity) (checked 20 Oct 2026)
- MDN, String: length (UTF-16 code units; counting characters and grapheme clusters) (checked 20 Oct 2026)
- MDN, TextEncoder (encodes to UTF-8) (checked 20 Oct 2026)
- RFC 3629, UTF-8 (1 to 4 bytes per code point) (checked 20 Oct 2026)
- 3GPP TS 23.038 V19.0.0 (ETSI TS 123 038), §4 and §6.2.1: GSM 7-bit alphabet, extension table, 160 and 70 character limits, national language tables (checked 20 Oct 2026)
- 3GPP TS 23.040 V19.0.0 (ETSI TS 123 040), §9.2.3.24.1 Concatenated short messages (153 and 67 per part) (checked 20 Oct 2026)
- Twilio documentation, What is the SMS character limit? (a provider's explanation of 160/153 and 70/67) (checked 20 Oct 2026)
- MySQL 8.4 Reference Manual, The CHAR and VARCHAR Types (length in characters; 65,535-byte row size) (checked 20 Oct 2026)
- MySQL 8.4 Reference Manual, The utf8mb4 Character Set (up to four bytes per character) (checked 20 Oct 2026)
- Python documentation, Text Sequence Type str (a sequence of Unicode code points) (checked 20 Oct 2026)
- The Go Programming Language Specification, String types (length in bytes) (checked 20 Oct 2026)
Need a custom dev tool for your team?
We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter