# @inquirer/ansi

> A lightweight package providing ANSI escape sequences for terminal cursor manipulation and screen clearing.

Latest version **2.0.8** (published 2026-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @inquirer/ansi
pnpm add @inquirer/ansi
yarn add @inquirer/ansi
bun add @inquirer/ansi
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2026-09-02 |
| First published | 2025-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=23.5.0 \|\| ^22.13.0 \|\| ^20.17.0 |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 21622 |
| Author | Simon Boudrias |
| Maintainers | sboudrias, mischah |
| Keywords | ansi, answer, answers, ask, base, cli, command, command-line, confirm, enquirer, generate, generator, hyper, input, inquire, inquirer, interface, iterm, javascript, menu, node, nodejs, prompt, promptly, prompts, question, readline, scaffold, scaffolder, scaffolding, stdin, stdout, terminal, tty, ui, yeoman, yo, zsh |

## Links

- npm: https://www.npmjs.com/package/@inquirer/ansi
- Repository: https://github.com/SBoudrias/Inquirer.js
- Homepage: https://github.com/SBoudrias/Inquirer.js/blob/main/packages/ansi/README.md
- Issues: https://github.com/SBoudrias/Inquirer.js/issues
- npm.io page: https://npm.io/package/@inquirer/ansi

## 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

- 2.0.8 (latest) — 2026-09-02
- 2.0.7 — 2026-05-29
- 2.0.6 — 2026-05-25
- 2.0.5 — 2026-04-06
- 2.0.4 — 2026-03-15
- 2.0.3 — 2026-01-11
- 2.0.2 — 2025-12-02
- 2.0.1 — 2025-11-17
- 2.0.0 — 2025-11-16
- 1.0.2 — 2025-11-08
- 1.0.1 — 2025-10-13
- 1.0.0 — 2025-09-14

## README

# @inquirer/ansi

A lightweight package providing ANSI escape sequences for terminal cursor manipulation and screen clearing.

# Installation

<table>
<tr>
  <th>npm</th>
  <th>yarn</th>
</tr>
<tr>
<td>

```sh
npm install @inquirer/ansi
```

</td>
<td>

```sh
yarn add @inquirer/ansi
```

</td>
</tr>
</table>

## Usage

```js
import {
  cursorUp,
  cursorDown,
  cursorTo,
  cursorLeft,
  cursorHide,
  cursorShow,
  eraseLines,
} from '@inquirer/ansi';

// Move cursor up 3 lines
process.stdout.write(cursorUp(3));

// Move cursor to specific position (x: 10, y: 5)
process.stdout.write(cursorTo(10, 5));

// Hide/show cursor
process.stdout.write(cursorHide);
process.stdout.write(cursorShow);

// Clear 5 lines
process.stdout.write(eraseLines(5));
```

Or when used inside an inquirer prompt:

```js
import { cursorHide } from '@inquirer/ansi';
import { createPrompt } from '@inquirer/core';

export default createPrompt((config, done: (value: void) => void) => {
  return `Choose an option${cursorHide}`;
});
```

## API

### Cursor Movement

- **`cursorUp(count?: number)`** - Move cursor up by `count` lines (default: 1)
- **`cursorDown(count?: number)`** - Move cursor down by `count` lines (default: 1)
- **`cursorTo(x: number, y?: number)`** - Move cursor to position (x, y). If y is omitted, only moves horizontally
- **`cursorLeft`** - Move cursor to beginning of line

### Cursor Visibility

- **`cursorHide`** - Hide the cursor
- **`cursorShow`** - Show the cursor

### Screen Manipulation

- **`eraseLines(count: number)`** - Clear `count` lines and position cursor at the beginning of the first cleared line

# License

Copyright (c) 2025 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
Licensed under the MIT license.

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