# widest-line

> Get the visual width of the widest line in a string - the number of columns required to display it

Latest version **6.0.0** (published 2026-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install widest-line
pnpm add widest-line
yarn add widest-line
bun add widest-line
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2026-01-24 |
| First published | 2015-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | string, character, unicode, width, visual, column, columns, fullwidth, full-width, full, ansi, escape, codes, cli, command-line, terminal, console, cjk, chinese, japanese, korean, fixed-width |

## Links

- npm: https://www.npmjs.com/package/widest-line
- Repository: https://github.com/sindresorhus/widest-line
- Homepage: https://github.com/sindresorhus/widest-line#readme
- Issues: https://github.com/sindresorhus/widest-line/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/widest-line

## Dependencies (1)

- [string-width](https://npm.io/package/string-width.md) ^8.1.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 6.0.0 (latest) — 2026-01-24
- 5.0.0 — 2023-10-28
- 4.0.1 — 2021-10-12
- 4.0.0 — 2021-04-21
- 3.1.0 — 2019-03-31
- 3.0.0 — 2019-03-18
- 2.0.1 — 2018-10-16
- 2.0.0 — 2017-11-30
- 1.0.0 — 2015-11-04

## README

# widest-line

> Get the visual width of the widest line in a string - the number of columns required to display it

Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.

Useful to be able to know the maximum width a string will take up in the terminal.

## Install

```sh
npm install widest-line
```

## Usage

```js
import widestLine from 'widest-line';

widestLine('古\n\u001B[1m@\u001B[22m');
//=> 2
```

## Related

- [string-width](https://github.com/sindresorhus/string-width) - Get the visual width of a string

---
_Source: https://npm.io/package/widest-line · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
