Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

chonkiejs

> AI 编程
Open source

CHONK your texts with Chonkie ✨ Type-friendly, light-weight, fast and super-simple chunking library

366 stars0 likes1 views
WebsiteGitHub

About

CHONK your texts with Chonkie ✨ Type-friendly, light-weight, fast and super-simple chunking library

We built chonkiejs while developing a TypeScript web app that needed fast, on-the-fly text chunking for RAG applications. After trying several existing libraries, we found them either too heavy or not flexible enough for our needs. chonkiejs is a port of the original chonkie library, but with some type-safety and a few extra features to make it more useful for TypeScript developers!

** Feature-rich**: All the CHONKs you'd ever need ✨ Easy to use: Install, Import, CHONK ⚡ Fast: CHONK at the max speed of TypeScript! tssssooooooom ** Light-weight**: No bloat, just CHONK ** Cute CHONK mascot**: psst it's a pygmy hippo btw ❤️ Moto Moto's favorite TypeScript library

Chonkie is a chunking library that "just works" ✨

[!NOTE] This library is not a binding but a port of the original chonkie library written in Python, to TypeScript. This library is still under active development and not at feature parity with the original chonkie library yet. Please bear with us!

Installation

bash
npm install @chonkiejs/core

Usage

typescript
import { RecursiveChunker } from '@chonkiejs/core';

// Create a chunker
const chunker = await RecursiveChunker.create({
  chunkSize: 512
});

// Chunk your text
const chunks = await chunker.chunk('Your text here...');

// Use the chunks
for (const chunk of chunks) {
  console.log(chunk.text);
  console.log(`Tokens: ${chunk.tokenCount}`);
}

Packages

Package Description Dependencies
@chonkiejs/core Local chunking (Recursive, Token, Sentence, Semantic, Code, Table, Fast) with character-based tokenization Zero
@chonkiejs/cloud Cloud-based chunkers (Semantic, Neural, Code, etc.) via api.chonkie.ai @chonkiejs/core
@chonkiejs/token HuggingFace tokenizer support for core chunkers @huggingface/transformers

Chunkers

All chunkers are available from @chonkiejs/core and follow the same pattern: await ChunkerClass.create(options) returns an instance, then await chunker.chunk(text) returns a Chunk[].

TokenChunker

Splits text into fixed-size token chunks with optional overlap.

typescript
import { TokenChunker } from '@chonkiejs/core';

const chunker = await TokenChunker.create({
  chunkSize: 512,      // max tokens per chunk (default: 512)
  chunkOverlap: 50,    // overlapping tokens between chunks (default: 0)
  tokenizer: 'character', // tokenizer model name or Tokenizer instance (default: 'character')
});
const chunks = await chunker.chunk(text);

RecursiveChunker

Recursively splits text using a hierarchy of rules: paragraphs → sentences → punctuation → words → characters. The most general-purpose chunker.

typescript
import { RecursiveChunker } from '@chonkiejs/core';

const chunker = await RecursiveChunker.create({
  chunkSize: 512,              // max tokens per chunk (default: 512)
  tokenizer: 'character',      // tokenizer model name or Tokenizer instance (default: 'character')
  minCharactersPerChunk: 24,   // min characters when merging splits (default: 24)
  // rules: RecursiveRules,    // custom split hierarchy (optional)
});
const chunks = await chunker.chunk(text);

SentenceChunker

Groups sentences into token-sized chunks, respecting sentence boundaries.

…

SemanticChunker

Detects natural chunk boundaries by computing embedding similarity between sliding sentence windows and splitting at low-similarity valleys.

…

CodeChunker

Splits source code into AST-aware chunks using tree-sitter. Requires web-tree-sitter and a language grammar.

typescript
import { CodeChunker } from '@chonkiejs/core';

// Using a language id (requires `tree-sitter-wasms` package)
const chunker = await CodeChunker.create({
  language: 'javascript',   // language id, .wasm path/URL, or Language instance
  chunkSize: 2048,
  tokenizer: 'character',
});
const chunks = chunker.chunk(sourceCode); // synchronous after create()

TableChunker

Splits markdown or HTML tables into smaller sub-tables, each repeating the original header.

typescript
import { TableChunker } from '@chonkiejs/core';

// Row mode (default): at most N data rows per chunk
const chunker = await TableChunker.create({
  tokenizer: 'row',  // 'row' for row-based, or any tokenizer for token-based (default: 'row')
  chunkSize: 3,      // max rows per chunk in row mode, max tokens in token mode (default: 3)
});
const chunks = chunker.chunk(markdownOrHtmlTable); // synchronous

FastChunker

High-throughput byte-based chunker powered by WASM. Does not count tokens — suited for pre-processing or when speed matters most.

…

Contributing

Want to help grow Chonkie? Check out CONTRIBUTING.md to get started! Whether you're fixing bugs, adding features, improving docs, or simply leaving a ⭐️ on the repo, every contribution helps make Chonkie a better CHONK for everyone.

Remember: No contribution is too small for this tiny hippo!

Acknowledgements

Chonkie would like to CHONK its way through a special thanks to all the users and contributors who have helped make this library what it is today! Your feedback, issue reports, and improvements have helped make Chonkie the CHONKIEST it can be.

And of course, special thanks to Moto Moto for endorsing Chonkie with his famous quote:

"I like them big, I like them chonkie in TypeScript" ~ Moto Moto... definitely did not say this

Citation

If you use Chonkie in your research, please cite it as follows:

bibtex
@software{chonkie2025,
  author = {Bhavnick Minhas and Shreyash Nigam},
  title = {Chonkie: A no-nonsense fast, lightweight, and efficient text chunking library},
  year = {2025},
  publisher = {GitHub},
  howpublished = {\\url{https://github.com/chonkie-inc/chonkie}},
}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptaichonkiechunkerchunking-algorithm

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.