sindresorhus/string-width
Last release: 1 month ago
Get the visual width of a string, returning the number of terminal columns required to display it. Useful for sizing and aligning command-line output, with support for fullwidth Unicode characters and stripping ANSI escape codes by default.
Project status
- Actively maintained, with recent
updatestagged as v8.2.1 (2026-04-27), v8.2.0 (2026-02-18), and v8.1.1 (2026-01-29), indicating ongoing work rather than a maintenance-only state. - Apparent cadence is a few months at most for feature and patch updates, for example, about 20 days between v8.1.1 and v8.2.0, then about 2 months until v8.2.1.
AI summary generated Today
Recent updates
v8.2.1
1 month agov8.2.1 updates `string-width` to correct how Hangul grapheme clusters are measured, specifically for decomposed Hangul jamo sequences and related combinations. The diff adds a dedicated Hangul cluster width calculation and expands the test suite to cover many Hangul edge cases.
v8.2.0
3 months agov8.2.0 focuses on improving `string-width` performance for plain ASCII input, and correcting rendered column width for minimally-qualified emoji sequences. The code changes also include additional internal logic around ANSI stripping and some dependency bumps that are not mentioned in the release notes.
v8.1.1
4 months agov8.1.1 is a targeted patch release. The release notes state it fixes a crash when handling Unicode Format characters such as U+0600.
v8.1.0
9 months agov8.1.0 is described as a performance improvement. The code change simplifies the emoji width calculation logic, but it also alters behavior: some emoji clusters that previously could be measured as single-width may now be treated as double-width.
Breakingv8.0.0
9 months agostring-width v8.0.0 raises the minimum Node.js requirement to Node 20 and claims improved handling of additional edge cases. The code changes substantially rework how grapheme clusters are segmented and measured, especially around emoji and width calculation for clusters containing trailing halfwidth or fullwidth forms.
Breakingv7.2.0
6/30/2024v7.2.0 focuses on handling additional edge cases in how `stringWidth` computes visual width for certain Unicode characters. The release notes are minimal and do not enumerate which code points or behaviors changed.
v7.1.0
1/22/2024v7.1.0 is a performance-focused release for string-width. The only documented change is an improvement in performance, and the diff shows code-level optimizations aimed at reducing per-call allocation overhead.
v7.0.0
10/28/2023v7.0.0 primarily updates Node.js engine requirements to Node 18 and switches the width-calculation logic to use newer East Asian Width data via get-east-asian-width. The release notes also claim Unicode data updates that fix some false positives, but the code diff shows additional changes around dependencies and module/type packaging.
Breakingv6.1.0
5/6/2023v6.1.0 claims a performance improvement. The code changes largely rework how grapheme clusters are iterated and how emoji widths are computed.
v6.0.0
5/6/2023v6.0.0 raises the minimum supported Node.js version to 16 and adds an option to control how ANSI escape codes are handled. The implementation also changes how strings are iterated (using Intl.Segmenter), improving compatibility for certain scripts.
BreakingFeatures