ESC

String Length Calculator

All calculations are updated instantly as you type

Length Statistics

0
Characters
0
Code Points
0
UTF-8 Bytes
0
UTF-16 Bytes
0
URL Encoded
0
Base64 Length
All processing happens in your browser. No data is sent to any server.

Usage Examples

ASCII Text

Calculate the length of simple ASCII text where each character uses 1 byte in UTF-8.

Unicode & Emoji

See how multi-byte characters like Japanese text and emojis affect byte counts differently.

URL String

Check how a URL with special characters expands when URL-encoded for web use.

Features

Real-Time Calculation

All measurements update instantly as you type, no button click needed

Multiple Encodings

See length in characters, code points, UTF-8, UTF-16, URL encoded, and Base64

Unicode Support

Correctly handles multi-byte characters, emojis, and surrogate pairs

Privacy First

All processing happens locally in your browser, no data sent to servers

How to Use?

1

Enter Text

Type or paste your text into the input field. Statistics update in real-time.

2

View Lengths

See all length measurements including characters, bytes in various encodings, and encoded lengths.

3

Copy Stats

Click the Copy Stats button to copy all length information to your clipboard.

Frequently Asked Questions

The "Characters" count is what JavaScript's string.length returns — UTF-16 code units. "Code Points" counts actual Unicode scalar values. Emoji and complex characters split the difference: a simple emoji like 😊 is 2 code units but 1 code point. A flag emoji like 🇩🇪 is 4 code units and 2 code points (two regional indicator symbols). For most ASCII text, both numbers are identical.

UTF-8 is variable-width: ASCII characters use 1 byte, Latin/accented characters use 2 bytes, most CJK characters use 3 bytes, and emoji use 4 bytes. UTF-16 is also variable but uses a minimum of 2 bytes: ASCII characters use 2 bytes, most characters use 2 bytes, and characters outside the Basic Multilingual Plane use 4 bytes. So ASCII text is always half the size in UTF-8 vs UTF-16. CJK text is often the same size or smaller in UTF-16.

URL encoding (percent-encoding) converts special characters and non-ASCII characters to %XX format. The space character becomes %20 (3 chars), adding 2 extra chars per space. A character like é becomes %C3%A9 (6 chars), expanding significantly. This measurement shows the length after full URL encoding — useful for checking if a query parameter or path segment will exceed length limits (browsers enforce 2,048-8,000 chars for full URLs depending on the browser).

Base64 encoding converts binary data to ASCII text for safe transmission. Every 3 bytes of input become 4 Base64 characters. The formula is ceil(bytes / 3) * 4, padded to a multiple of 4. A 10-byte UTF-8 string becomes approximately 16 Base64 characters. This measurement is useful when calculating API payload sizes, email attachment sizes, or data URI lengths.

JavaScript uses UTF-16 encoding internally. The .length property counts UTF-16 code units, not characters. For all ASCII and most Latin text, .length equals the character count. But emoji and characters in Unicode planes above U+FFFF require 2 UTF-16 code units (a surrogate pair) — so .length over-counts them. Use Array.from(str).length or [...str].length for accurate character (code point) counting.

It depends on the emoji. A simple emoji like 😊 (U+1F60A): 2 UTF-16 code units, 1 code point, 4 UTF-8 bytes. A flag emoji like 🇩🇪: 4 UTF-16 code units, 2 code points, 8 UTF-8 bytes. A skin-tone modifier emoji like 👋🏽: 4 UTF-16 code units, 2 code points, 8 UTF-8 bytes. A family emoji (👨‍👩‍👧) built from ZWJ sequences: many code units and code points. The tool counts each layer correctly.

A Unicode code point is a number assigned to a character (e.g., U+1F60A for 😊). A code unit is the storage unit for a specific encoding — UTF-8 uses 8-bit units, UTF-16 uses 16-bit units. Most characters fit in one UTF-16 code unit (the Basic Multilingual Plane, U+0000–U+FFFF). Characters outside this range (emoji, some historical scripts) require two UTF-16 code units (a surrogate pair).

No. All length calculations run locally in your browser via JavaScript. Paste API keys, passwords, or sensitive text without concern — nothing is transmitted anywhere.

Why String Length Is Not Just .length

If you have ever been surprised that an emoji takes 2 characters in JavaScript or that a Japanese string is 3x bigger in UTF-8 than you expected, this tool is for you. It shows the real size of your text across multiple encodings so you know exactly what you are dealing with.

Six Measurements at a Glance

Character count, Unicode code points, UTF-8 bytes, UTF-16 bytes, URL encoded length, and Base64 length - all updating in real-time as you type. No need to write code or check documentation to figure out how big your string actually is.

When Developers Need This

Checking database column sizes before inserting data, verifying URL length limits, calculating payload sizes for APIs, debugging encoding issues with international text, or figuring out why that emoji broke your VARCHAR(255) column. These are real problems this tool solves instantly.

Unicode Done Right

The tool correctly handles surrogate pairs, combining characters, and emoji sequences. It distinguishes between what JavaScript calls "length" and what Unicode defines as code points - a distinction that matters when you are working with international text or emoji-heavy content.

No Server, No Tracking

Everything runs in your browser with JavaScript. Paste API keys, passwords, or sensitive data without worry - nothing is transmitted anywhere. The calculations happen locally on your machine.

Security and Privacy

Your data security is our priority

Local Processing

All processing happens in your browser

No Data Transfer

Your data is not sent to our servers

No Data Storage

No data is stored or shared

SSL Encryption

SSL encryption for secure connection

Also on MoreOnlineTools