string-width
Get the visual width of strings for precise text layout.
- Status
- Generally available
- Last checked
- Checked · Oct 13, 2026
- License
- Open source
- Pricing
- Free tier · from $0
What it is
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.
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.
When it fits — and when it doesn’t
A good fit 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.
Look elsewhere if
Real-time text processing applications where performance is critical.
Large-scale data processing tasks where the overhead of string manipulation could be significant.
Known weaknesses
Each one links to the public issue, changelog or docs page it came from, where we have one.
- 01
Limited functionality for complex text formatting
string-width only calculates the width of strings and does not handle more complex text formatting or alignment tasks.
- 02
No built-in support for right-to-left languages
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.
- 03
Does not account for font metrics or rendering differences
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.
- 04
Does not handle combining characters well
The tool may struggle with Unicode combining characters that modify the preceding character, potentially leading to inaccurate width calculations for such text.
What it does well
Supports Unicode characters for accurate width calculation.
Lightweight and easy to integrate into projects.
No external dependencies, making it simple to use.
Pricing
- Free tier
- YesOpen source — free to use
- Paid from
- $0
- Model
- Flat rate
- Enterprise plan
- No
Pricing not independently confirmed — check the vendor’s page.
Performance benchmarks
How Fast Is It?
Set up string-width
Setup steps, common gotchas and what to check after 30 days.
Get the badge
A small badge for string-width’s README or site: its name, “Tracked on AI Navigator”, and the availability status and check month from this page. It updates as the catalog does.
Markdown
[](https://navigateaitools.com/explorer/tool/string-width)HTML
<a href="https://navigateaitools.com/explorer/tool/string-width"><img src="https://navigateaitools.com/badge/string-width.svg" alt="string-width — tracked on AI Navigator" height="58"></a>