Language calculators

String Length Calculator

Updated Sep 29, 2026 By Infinity Calculator
Input String
Size: 38 bytes|Characters: 38
Plain-text files only. Loads and calculates automatically.
The remote server must allow cross-origin (CORS) requests.
Quick actions
Options
When unchecked, newline characters are excluded from the total character count.
Excludes outer whitespace from all counts without editing your text.
Shows a usage progress bar below.
Real-Time Analysis
Your string is 38 characters long.
38
Total Length
chars
32
Non-Whitespace
chars
7
Word Count
words
1
Line Count
lines
38
UTF-8 Byte Size
bytes
76
UTF-16 Byte Size
bytes
0.02
Approx. Pages
pages (1,800 chars/page)
38
UTF-16 Code Units
units (JS string length)
Character Breakdown
Step-by-Step Solution

Introduction

This String Length Calculator counts the characters in any text you type, paste, or upload. Just add your words, and the tool shows the string length right away.

You also get more than a simple character count. The calculator shows your word count, line count, and how many bytes your text uses in UTF-8 and UTF-16. A chart breaks your text into letters, digits, spaces, and punctuation, so you can see what your string is made of. If you need a deeper look at vocabulary and readability instead of raw characters, the Word Count Calculator is the better companion tool.

Writers and publishers can check text against common limits, like 280 characters for a post on X, 160 for an SMS, or a custom limit you set. A colored bar tells you how much room is left, or how far over you are.

Turn newlines on or off, trim extra spaces, and pick the byte unit you want. The step-by-step section shows the math behind every number, so you always know how the count was made.

How to use our String Length Calculator

Type or paste your text, pick a few options, and the string length calculator shows your character count, word count, line count, byte size, and a full character breakdown.

Auto-Calculate: Leave this box checked to see your results update live as you type. Uncheck it if you want to press the Calculate button yourself.

Enter or paste your text here: Put your string in the big text box. The bar under it shows the byte size and character count right away.

Import from file: Choose a plain-text file (like .txt, .csv, .json, or .md) from your device. The text loads into the box and is counted for you. Files must be under 5 MB.

Load from URL: Paste a web address that points to raw text, then click Load. The site you link to must allow cross-origin requests.

Quick actions: Click Load Sample to try demo text, Copy Input to copy your text, or Clear to empty the box and reset the numbers.

Include newlines in length count: Keep this checked to count line breaks as characters. Uncheck it to leave them out of the total.

Trim leading & trailing whitespace: Check this to skip spaces at the start and end of your text. Your text stays the same; only the counts change.

Compare to character limit: Pick a limit such as Twitter/X (280), SMS (160), or Open Graph (200). A bar shows how much of the limit you used and how many characters are left.

Custom limit: Choose "Custom" in the list above, then type your own limit as a whole number. Use this for headlines, book blurbs, or any word count rule you follow.

Display byte sizes in: Choose bytes, KB, KiB, MB, or MiB to set how the UTF-8 and UTF-16 sizes are shown.

Calculate and Reset: Click Calculate to run the counts, or Reset to put every option and the text back to the start.

What Is String Length?

A string is any piece of text: a word, a sentence, a name, or a whole page. The string length is how many characters that text holds. Letters, numbers, spaces, punctuation marks, and emoji all count as characters. The word "cat" has a length of 3. The words "cat dog" have a length of 7, because the space counts too.

Characters vs. Bytes

Characters and bytes are not the same thing. A character is what you see. A byte is how much room that character takes up in computer memory or in a file. In UTF-8, a plain English letter like "a" uses 1 byte.1 An accented letter like "é" uses 2 bytes.1 A Chinese or Japanese character uses 3 bytes.1 An emoji like 🚀 uses 4 bytes.1 So a short line of text with emoji can be much bigger in bytes than it looks. UTF-16 works differently and gives most characters 2 bytes each, and 4 bytes for emoji and rare symbols.2 If you are feeding text to an AI model rather than a database, characters and bytes give way to tokens, which you can estimate with the Token Calculator.

Why Character Limits Matter

Many places on the web cut your text off at a set number of characters. Here are common limits:

  • Twitter/X post: up to 280 characters, but X counts each emoji and each Chinese, Japanese or Korean character as 2, and every link as 23.3
  • SMS text message: up to 160 characters in the standard GSM 7-bit alphabet, or up to 70 UCS2 characters when the message uses characters outside it.4
  • Meta description: Google sets no limit on how long a meta description can be, but it trims the snippet in search results as needed to fit the device width.5
  • Open Graph description: a common target is about 200 characters for social media previews.

Databases also set limits. In MySQL, a column declared VARCHAR(255) holds up to 255 characters, and a longer value is truncated with a warning, or rejected in strict SQL mode.6 Checking your length first saves you from broken posts and lost words.

Words, Lines, and Pages

Word count splits your text at every space or line break. Line count tells you how many rows your text fills. Page count is an estimate based on 1,800 characters per page, a figure some editors and translators use when they charge by the page. These numbers help writers plan how long an article, script, or book chapter will run.

Whitespace and Newlines

Whitespace means spaces, tabs, and line breaks. Some systems count them and some do not. Trimming removes extra spaces at the start and end of your text, which is helpful when you paste from another program and pick up hidden spaces. Newlines are the invisible characters that start a new line, and they still take up space in your total count.


Formulas used

Counted string length after trim and newline options
L = L_{\text{raw}} - L_{\text{trimmed}} - L_{\text{newlines}}
Character type breakdown
L = n_{\text{letters}} + n_{\text{digits}} + n_{\text{spaces}} + n_{\text{punct}} + n_{\text{other}}
Non-whitespace character count
L_{\text{non-ws}} = L - n_{\text{whitespace}}
UTF-8 byte size 1
B_{8} = 1 \cdot n_{1} + 2 \cdot n_{2} + 3 \cdot n_{3} + 4 \cdot n_{4}
UTF-16 byte size 2
B_{16} = 2 \cdot n_{\text{BMP}} + 4 \cdot n_{\text{supp}}
Approximate page count (1,800 chars per page)
P = \frac{L}{1800}
Character limit usage percentage
\text{Usage} = \frac{L}{L_{\max}} \times 100\%
Byte size unit conversion 7
S_{\text{unit}} = \frac{B}{f}, \quad f \in \{1,\ 1000,\ 1024,\ 10^{6},\ 1048576\}

Frequently asked questions

Why does an emoji count as one character but four bytes?

You see one picture, so it counts as one character. But computers need more room to store it. In UTF-8, most emoji take 4 bytes. Some emoji, like flags and family emoji, are built from several code points, so they may count as more than one character.

What is the difference between Total Length and UTF-16 Code Units?

Total Length counts real characters (code points), the way a person reads them.

UTF-16 Code Units is the number JavaScript, Java, and C# report when you ask for string length. Emoji and rare symbols count as 2 there. For plain English text, both numbers match.

Why is my count different from Microsoft Word?

Word and Google Docs count words and characters with their own rules. They may skip footnotes, headers, or text boxes. This tool counts every character you paste, exactly as it is. Small gaps are normal.

How do I count characters without spaces?

Look at the Non-Whitespace box in the results. It shows your length after spaces, tabs, and line breaks are removed. Editors and translators often bill by this number.

Why did my SMS split into more than one message?

A message in the standard GSM 7-bit alphabet can hold up to 160 characters.4 If you add an emoji or a character outside that alphabet, such as some accented letters, the message switches to UCS2 and holds up to 70 characters.4 Check the character breakdown to see if you used special characters.

Does a link count as 23 characters like on X?

No. This tool counts the real characters in the link. X counts every link as 23 characters, whatever its length, so your post may fit even if this tool says you are a bit over.3 X also counts each emoji as 2 characters, while this tool counts it as 1.3

Why did Load from URL fail?

Most websites block other sites from reading their pages. This is called a CORS block. It works best with raw text files. If it fails, open the link yourself, copy the text, and paste it in the box.

What counts as one word?

Any group of characters between spaces or line breaks. So "e-mail" is one word, and "3.14" is one word. Word count ignores your newline setting, because line breaks always split words.

What falls under Other / Special in the breakdown?

Anything that is not a letter, digit, space, or punctuation mark. That includes tabs, line breaks, emoji, and control characters. A high number here often means hidden formatting came along when you pasted.

How exact is the page estimate?

It uses 1,800 characters per page, a figure some editors and translators use. Your real page count changes with font, size, margins, and spacing, so treat it as a quick guide, not a final number.

Why is the UTF-16 size about double the UTF-8 size?

UTF-8 gives plain English letters just 1 byte. UTF-16 gives almost every character 2 bytes. So English text is about twice as big in UTF-16. For Chinese, Japanese, or Korean text, UTF-16 can be smaller.


Sources

  1. Yergeau F. RFC 3629: UTF-8, a transformation format of ISO 10646. Internet Engineering Task Force. 2003;§ 3, UTF-8 definition. Accessed September 29, 2026.
  2. Hoffman P, Yergeau F. RFC 2781: UTF-16, an encoding of ISO 10646. Internet Engineering Task Force. 2000;§ 2, UTF-16 definition. Accessed September 29, 2026.
  3. Counting Characters. X Documentation. X Corp.. Character weights; URL handling. Accessed September 29, 2026.
  4. ETSI TS 123 038 V17.0.0 (3GPP TS 23.038 Release 17): Alphabets and language-specific information. ETSI / 3GPP. 2022;clause 4, SMS Data Coding Scheme. Accessed September 29, 2026.
  5. Control your snippets in search results. Google Search Central. Google. Best practices for creating quality meta descriptions. Accessed September 29, 2026.
  6. MySQL 8.4 Reference Manual, 13.3.2 The CHAR and VARCHAR Types. MySQL 8.4 Reference Manual. Oracle. § 13.3.2. Accessed September 29, 2026.
  7. Prefixes for binary multiples. National Institute of Standards and Technology. Accessed September 29, 2026.