string-width
Get the visual width of strings for precise text layout.
Pricing
Free tier
Flat rate
Adoption
→StableLicense
Open Source
Data freshness
Aging · Jun 8, 2026Overview
What is string-width?
string-width is a utility that calculates the number of columns required to display a string, which is essential for aligning and formatting text in various applications. It supports Unicode characters, making it useful for internationalized software.
Key differentiator
“string-width stands out as a lightweight, dependency-free library for calculating string width, making it ideal for developers who need precise control over text formatting in their projects.”
Capability profile
Capability Radar
Honest assessment
Strengths & Weaknesses
↑ Strengths
↓ Weaknesses
string-width only calculates the width of strings and does not handle more complex text formatting or alignment tasks.
The tool primarily supports left-to-right text, which may lead to incorrect width calculations for right-to-left languages like Arabic and Hebrew without additional custom handling.
string-width calculates the number of columns based on character widths but does not consider how different fonts might render these characters, which can lead to discrepancies in actual display width.
The tool may struggle with Unicode combining characters that modify the preceding character, potentially leading to inaccurate width calculations for such text.
Fit analysis
Who is it for?
✓ Best for
Developers working on CLI tools who need precise text alignment and formatting.
Projects requiring accurate width calculation for internationalized strings.
Applications that display formatted text in a terminal or console environment.
✕ Not a fit for
Real-time text processing applications where performance is critical.
Large-scale data processing tasks where the overhead of string manipulation could be significant.
Cost structure
Pricing
Free Tier
Available
Open source — free to use
Starts at
$0
Model
Flat rate
Enterprise
None
Performance benchmarks
How Fast Is It?
Ecosystem
Relationships
Works well with
Integrations
Next step
Get Started with string-width
Step-by-step setup guide with code examples and common gotchas.