# @anthropic-ai/tokenizer

> Claude tokenizer

Latest version **0.0.4** (published 2023-07-05) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @anthropic-ai/tokenizer
pnpm add @anthropic-ai/tokenizer
yarn add @anthropic-ai/tokenizer
bun add @anthropic-ai/tokenizer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-07-05 |
| First published | 2023-06-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 108 |
| Author | Anthropic |
| Maintainers | bkrausz, ejlangev-ant, nikhil-anthropic, jenan-anthropic, benjmann, jspahrsummers |

## Links

- npm: https://www.npmjs.com/package/@anthropic-ai/tokenizer
- Repository: https://github.com/anthropics/anthropic-tokenizer-typescript
- npm.io page: https://npm.io/package/@anthropic-ai/tokenizer

## Dependencies (2)

- [tiktoken](https://npm.io/package/tiktoken.md) ^1.0.10
- [@types/node](https://npm.io/package/@types/node.md) ^18.11.18

## Recent versions

- 0.0.4 (latest) — 2023-07-05
- 0.0.3 — 2023-06-28
- 0.0.2 — 2023-06-28
- 0.0.1 — 2023-06-28

## README

# Anthropic TypeScript Tokenizer

[![NPM version](https://img.shields.io/npm/v/@anthropic-ai/tokenizer.svg)](https://npmjs.org/package/@anthropic-ai/tokenizer)

This package provides a convenient way to check how many tokens a given piece of text will be.

## Installation

```sh
npm install --save @anthropic-ai/tokenizer
# or
yarn add @anthropic-ai/tokenizer
```

## Usage

```js
import { countTokens } from '@anthropic-ai/tokenizer';

function main() {
  const text = 'hello world!';
  const tokens = countTokens(text);
  console.log(`'${text}' is ${tokens} tokens`);
}
main();
```

## Status

This package is in beta. Its internals and interfaces are not stable
and subject to change without a major semver bump;
please reach out if you rely on any undocumented behavior.

We are keen for your feedback; please email us at [support@anthropic.com](mailto:support@anthropic.com)
or open an issue with questions, bugs, or suggestions.

## Requirements

The following runtimes are supported:

- Node.js version 12 or higher.
- Deno v1.28.0 or higher (experimental).
  Use `import { countTokens } from "npm:@anthropic-ai/tokenizer"`.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.

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