Language calculators

String Length Calculator

Updated Aug 29, 2026 By Jehan Wadia
Rate Formulas
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 meta description, 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), meta description (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. To see how long a file of that size takes to move across a network, try the Download Time Calculator or the Data Transfer Calculator.

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. An accented letter like "é" uses 2 bytes. A Chinese or Japanese character uses 3 bytes. An emoji like 🚀 uses 4 bytes. 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. 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 and price out using the Token Cost Calculator. For verifying that a copied or uploaded string arrived unchanged, a Checksum Calculator or Hash Value Calculator is the right next step.

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: 280 characters
  • SMS text message: 160 characters per message
  • Meta description: about 160 characters before Google trims it
  • Open Graph description: about 200 characters for social media previews

Databases also set limits. A field marked VARCHAR(255) will only hold 255 characters, and anything longer gets cut or rejected. Checking your length first saves you from broken posts and lost words. Social publishers who track how those posts perform after the character trimming can follow up with the Engagement Rate Calculator or the CTR Calculator.

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, which is a common standard for editors, translators, and publishers who charge by the page. These numbers help writers plan how long an article, script, or book chapter will run. From there, the Reading Time Calculator turns your length into minutes on the page, the Speech Time Calculator and Words to Minutes Calculator handle scripts read aloud, the Audiobook Calculator estimates recorded runtime, and the KDP Cover Calculator converts a finished page count into spine and cover dimensions for print. Typists measuring how fast they can produce a given string can check the WPM Calculator.

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. To express one count as a share of another, such as how much of a limit a section uses, the Percentage Calculator and Percent Difference Calculator can help.


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
B_{8} = 1 \cdot n_{1} + 2 \cdot n_{2} + 3 \cdot n_{3} + 4 \cdot n_{4}
UTF-16 byte size
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
S_{\text{unit}} = \frac{B}{f}, \quad f \in \{1,\ 1000,\ 1024,\ 10^{6},\ 1048576\}

Frequently asked questions

Is my text private when I use this tool?

Yes. All counting happens in your own browser. Your text is never sent to a server or saved. The one exception is the Load from URL button, which asks that website for its text.

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.

Does the tool count tabs and hidden spaces?

Yes. Tabs, double spaces, and line breaks are all real characters, so they add to your total. Use the Trim option to drop spaces at the start and end, and turn off Include newlines to leave out line breaks.

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.

Does it count HTML tags in my text?

Yes. Tags like <p> are plain text, so every bracket and letter counts. If you only want the visible words, paste the text without the code.

Why did my SMS split into more than one message?

Plain English text fits 160 characters per SMS. But if you add an emoji or an accented letter, the whole message switches to a different format and drops to 70 characters. 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 shortens every link to a set number in its own count, so your post may fit even if this tool says you are a bit over.

How big a file or text can I paste?

Uploaded files must be under 5 MB. Pasting works for very long text too, but a page with hundreds of thousands of characters may feel slow. If that happens, uncheck Auto-Calculate and press Calculate when you are ready.

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 common standard for editors and translators. Your real page count changes with font, size, margins, and spacing, so treat it as a quick guide, not a final number.

Can I check a database field size with this?

Yes. Pick Custom under the limit menu and type your field size, such as 255. Note that some databases count bytes, not characters, so compare your UTF-8 byte size too.

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.

Do the numbers update as I type?

Yes, as long as Auto-Calculate is checked. The bar under the text box shows the live byte size and character count, and every result card updates with each keystroke.