Grapheme Cluster Counter
text.count_graphemes
Overview
You pass text (or a file_ref); we count grapheme clusters — what users perceive as characters — using Unicode extended grapheme boundaries, correctly handling emoji sequences and combining marks. Optionally return individual segments. Do not use this for code-point or byte sizing.
Most string.length() functions count code units, not what users see — we count what humans perceive as characters.
Reliability
VERIFIABLE and deterministic on this deployment; grapheme boundaries depend on the JVM Unicode version (reported as unicode_version=runtime_default). Input validation (not retryable): neither text nor file_ref; both provided; text too long; invalid normalization.
Context footprint
Eliminates common off-by-N errors with emoji and combining characters. Accepts inline text up to 1,000,000 chars or file input via file_ref (up to 2 MB). Upload files via POST /v1/files/upload before passing file_ref. A successful call costs 1 execution credit.
When to use it
When you need user-visible character count for UI fields, SMS, or social limits.
When you need storage or protocol sizing — use text.count_bytes instead.
Scope
Non-goals
- Does not count code points or bytes
- Does not normalize emoji
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
File limits
Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.
| Limit | Value | Limited by |
|---|---|---|
| Maximum size per input file | 1.9 MiB | Skill maximum |
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| text | string | No | Bounded inline text source. Required unless file_ref is provided. |
| file_ref | string | No | Tenant-scoped opaque text-file reference. Omit it to use the required inline text; never send both. |
| normalization | string | No | Unicode normalization; omit it for none. |
| return_segments | boolean | No | Whether closed grapheme-cluster spans are returned; omit it for false. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| skill | string | Yes | Producing stable skill key. |
| count | integer | Yes | Counted grapheme clusters. |
| unit | string | Yes | Measurement unit for the returned grapheme-cluster total. |
| policy | string | Yes | Applied grapheme policy. |
| unicode_version | string | Yes | Pinned Unicode data version. |
| normalized | boolean | Yes | Whether normalization was applied. |
| normalization | string | Yes | Applied Unicode normalization. |
| segments | array | No | Bounded optional array of returned grapheme-cluster spans in source order. The item shape is defined by the nested schema and the array contains from 0 through 2000000 items. |
| offset_unit | string | No | Unit of start_offset and end_offset when segments are returned. |
| warnings | array | Yes | Bounded warning array containing from 0 through 10000 items, where each item is one non-fatal advisory string. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"text.count_graphemes","input":{"text":"Hello 👋🏽"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("text.count_graphemes", {"text":"Hello"});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not count code points or bytes
- Does not normalize emoji
- Code point counting (use text.count_characters)
- Byte estimation (use text.count_bytes)
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "text.count_graphemes",
"input": {
"text": "Hello"
}
}Examples
Basic ASCII
{
"text": "Hello"
}{
"warnings": [
"Unicode version is provided by the runtime and not explicitly pinned."
],
"normalization": "none",
"count": 5,
"skill": "text.count_graphemes",
"policy": "unicode_extended_grapheme_cluster",
"unit": "grapheme_cluster",
"unicode_version": "runtime_default",
"normalized": false
}Family emoji is one grapheme
{
"text": "👨👩👧👦"
}{
"warnings": [
"Unicode version is provided by the runtime and not explicitly pinned."
],
"normalization": "none",
"count": 1,
"skill": "text.count_graphemes",
"policy": "unicode_extended_grapheme_cluster",
"unit": "grapheme_cluster",
"unicode_version": "runtime_default",
"normalized": false
}Recommended use cases
- Validate visible text length for UI fields
- Count emoji accurately
- Measure user-perceived string length
Avoid for
- Code point counting (use text.count_characters)
- Byte estimation (use text.count_bytes)
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.