</>PackageGraphPackageGraph

string-width

npmv8.2.2TypeScript

Get the visual width of a string - the number of columns required to display it

Safe to adopt

Yes — string-width scores well across adoption, maintenance, weight, supply chain, and licensing. 508.6M downloads per week and 3 known dependents. Last published 63 days ago. 6 releases in the last 2 years.

  • AAdoption: grade A, Excellent.

    508.6M downloads per week and 3 known dependents.

  • AMaintenance: grade A, Excellent.

    Last published 63 days ago. 6 releases in the last 2 years.

  • AWeight: grade A, Excellent.

    Pulls in 2 transitive packages, about 26 KB installed (at least — some of the tree is still being crawled).

  • BSupply chain: grade B, Good.

    This package has a single maintainer (bus factor of 1).

  • ALicense: grade A, Excellent.

    MIT — permissive, with no copyleft found in the dependency tree.

Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.

Install cost

What you actually take on by adding string-width to a project.

2
Direct dependencies

Runtime packages this one declares itself.

2
Total installed

Distinct packages in the full runtime tree, deduplicated the way a package manager would.

26 KB
Install size

Unpacked size of this package plus its entire runtime tree.

1
Tree depth

Longest resolved dependency chain below this package.

Part of this dependency tree has not been crawled yet, so these figures are a lower bound rather than a final total.

Licenses in the dependency tree

MIT

Every license you inherit by installing string-width, not just its own. Check this before a legal review, not after.

Compatibility

Node.js
node >=20
Module format
ESM only
TypeScript
Types included
Install scripts
None

Quick start

A usage example from the string-width README.

import stringWidth from 'string-width';

stringWidth('a');
//=> 1

stringWidth('古');
//=> 2

stringWidth('\u001B[1m古\u001B[22m');
//=> 2

string-width vs the alternatives

Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.

PackageWeekly downloadsDependentsLicenseLast release
string-widththis page508.6M3MIT2 months ago
get-east-asian-width77.1M1MIT7 days ago
terminal-link21.2M1MIT6 days ago
string-length03MIT6 days ago
supports-hyperlinks40.3M1MIT6 days ago
log-symbols01MIT6 days ago

Dependencies

Declared by string-width v8.2.2. Runtime dependencies are installed with the package; dev dependencies are not.

Runtime (2)

Dev (3)

ava ^6.4.1tsd ^0.33.0xo ^1.2.3

Used by

Popular packages that depend on string-width.

Relationship graph

Dependencies (left) and dependents (right) of string-width.

get-east-asian-wi…cliuiyargsorastring-width
string-width dependencies dependents

Frequently installed together

Release history

6 releases in the last two years, typically about 73 days apart.

Recent versions of string-width
VersionPublishedSizeLicense
8.2.2latest2 months ago11 KBMIT
8.2.14 months ago11 KBMIT
8.2.06 months ago9.0 KBMIT
8.1.17 months ago7.9 KBMIT
8.1.01 year ago7.8 KBMIT
8.0.01 year ago8.7 KBMIT
7.2.02 years ago7.6 KBMIT
7.1.02 years ago6.5 KBMIT
7.0.02 years ago6.4 KBMIT
6.1.03 years ago5.7 KBMIT
6.0.03 years ago5.8 KBMIT
5.1.24 years ago5.6 KBMIT
5.1.14 years ago5.7 KBMIT
5.1.04 years ago5.6 KBMIT
4.2.35 years ago5.0 KBMIT

Overview

string-width is an npm package that get the visual width of a string - the number of columns required to display it. It is extremely widely used, with about 508.6M downloads per week and 3 known dependents in the graph. The latest version is 8.2.2, released under the MIT license.

Who should use it

Teams working in the npm ecosystem who need get the visual width of a string - the number of columns required to display it and value a battle-tested, widely-adopted solution.

When not to use it

Consider an alternative if you need to or if a more actively-maintained option better fits your npm stack.

Pros

  • Large, well-established user base (508.6M weekly downloads).
  • Ships TypeScript type definitions.
  • Clear open-source license (MIT).

Cons

  • No significant drawbacks detected from available metadata.

Auto-generated from collected registry metadata. No external claims are inferred.

Maintainers

Keywords

Funding

Frequently asked questions

Should I use string-width?

Yes — string-width scores well across adoption, maintenance, weight, supply chain, and licensing. 508.6M downloads per week and 3 known dependents. Last published 63 days ago. 6 releases in the last 2 years.

How do I install string-width?

Run `npm install string-width` to add string-width to your npm project.

How many dependencies does string-width have?

string-width declares 5 direct dependencies and pulls in 2 packages in total once its runtime tree is resolved totalling about 26 KB on disk.

What license is string-width released under?

string-width is distributed under the MIT license.

How popular is string-width?

string-width has approximately 508,567,931 downloads per week and 3 known dependent packages.

Is string-width still maintained?

The most recent release of string-width (v8.2.2) was published 2 months ago.

Does string-width run install scripts?

No. string-width does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.