jieba-rs: Chinese word segmentation in Rust, with bindings for Node, Python, PHP and WASM
The Jieba Chinese Word Segmentation Implemented in Rust
At a glance
- What is it?
- jieba-rs is a Rust implementation of the Jieba Chinese word segmentation algorithm, published on crates.io as jieba-rs and used as the engine behind Node, Python, PHP, R and WebAssembly bindings. It is a library for people building search or NLP pipelines in Rust, not a standalone tool.
- Who is it for?
- Adopt jieba-rs if you are already writing Rust or need a Chinese tokenizer inside a Rust service, a Tantivy index, or a WASM bundle, and you want the MIT licence and the optional tfidf and textrank features. Do not adopt it if you want a command line tool or a server: the repository is a library workspace, and the README shows no CLI entry point.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 19, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What jieba-rs solves, and why Chinese text needs a segmenter at all
Chinese is written without spaces between words, so a search index or a tokenizer that splits on whitespace gets one token per sentence. jieba-rs is the Rust port of the Jieba algorithm, which produces word boundaries for Chinese text. The README describes it in one line: "The Jieba Chinese Word Segmentation Implemented in Rust." That is the whole scope. It is not a general NLP toolkit, it does not do part-of-speech tagging, and it does not train models. It segments, and optionally it extracts keywords.
The audience is narrow and specific. You are building a search index over Chinese documents, a text classifier, or a pipeline that needs word counts, and you are working in Rust or in a language that has a binding to this crate. The README lists bindings for NodeJS, PHP, Python, R, Emacs, WebAssembly, and two Tantivy adapters. If you are in Python and just want segmentation, the original Python Jieba is the shorter path; jieba-rs matters when you want the same algorithm inside a Rust binary or a WASM module, or when you want the performance work described in the linked benchmark posts.
One design consequence is worth stating up front. The crate is a library, and the repository is a Cargo workspace with members capi, jieba, jieba-macros and examples/weicheng. There is no binary target described in the README, so if you want a command line segmenter you will be writing the main function yourself.
How the segmentation works: Jieba::new, cut, and the embedded dictionary
The mechanism visible in the README is a dictionary-driven segmenter wrapped in a struct. You construct a Jieba instance, then call cut on a string with a boolean second argument. The README's example passes false and asserts this output for the input "我们中出了一个叛徒": ["我们", "中", "出", "了", "一个", "叛徒"]. The boolean is the HMM switch in Jieba's design; the README does not explain it, which is a gap for a new user.
The dictionary is embedded by default. The feature list says default-dict "enables embedded dictionary, this features is enabled by default." That is what makes Jieba::new() work with no file loading step and no path argument in the example. The trade-off is that the vocabulary is fixed at build time unless you use the custom dictionary APIs, which the README does not document at all.
Two optional features add keyword extraction on top of segmentation: tfidf enables a TF-IDF keywords extractor and textrank enables a TextRank keywords extractor. These are off unless you ask for them, which keeps the default dependency surface small. The workspace Cargo.toml shows the supporting crates the implementation pulls in, including cedarwood, rustc-hash, bytecount with runtime-dispatch-simd, and include-flate, which is consistent with a compressed embedded dictionary loaded lazily. The README does not describe the internal data flow beyond that, so treat the crate as a black box that maps a string to a vector of string slices.
Installing jieba-rs and running a first segmentation
Installation is a Cargo dependency. The README says to add it to Cargo.toml with version 0.10, and notes that on Rust 2015 you also need extern crate jieba_rs at the crate root. The current workspace version is 0.10.3, released on 2026-07-19, and the edition in the workspace manifest is 2024.
[dependencies]
jieba-rs = "0.10"With that in place, the README's example is the first real use. It constructs the segmenter, cuts a string, and asserts the expected words. Run it and you should see the assertion pass; if it fails, you are looking at a different dictionary or a modified input.
use jieba_rs::Jieba;
fn main() {
let jieba = Jieba::new();
let words = jieba.cut("我们中出了一个叛徒", false);
assert_eq!(words, vec!["我们", "中", "出", "了", "一个", "叛徒"]);
}If you want keyword extraction as well, enable the features at the dependency level. The README gives this exact form:
[dependencies]
jieba-rs = { version = "0.10", features = ["tfidf", "textrank"] }The README does not show the call sites for the TF-IDF or TextRank extractors, only the feature flags. Check docs.rs for those APIs before planning around them.
There is also a benchmark command in the README, useful if you want to measure the crate on your own hardware rather than trust the linked blog posts:
cargo bench --all-featuresThe limitation that matters: dictionary dependence and undocumented customisation
The single largest constraint is that segmentation quality is a function of the dictionary, and the README documents the dictionary only as a feature flag. default-dict is enabled by default and embeds a dictionary, but the README never shows how to load a custom one, how to add a word, or how to replace the embedded data. If your corpus is full of product names, names of people, or domain jargon, the default vocabulary will split them incorrectly and the README gives you no documented path to fix that. In the Python Jieba ecosystem this is a well-known workflow; here it is absent from the front page.
The second limitation is the missing explanation of the boolean in cut. The example passes false, and the README does not say what true does. A reader cannot tell from the README whether it enables HMM for unknown words, changes the output type, or something else. That is a documentation gap, not necessarily a design flaw, but it means you should read docs.rs before assuming behaviour.
The third case is where jieba-rs is simply the wrong tool. If you need a tokenizer for a language other than Chinese, this crate does nothing for you. If you need a running service with an HTTP API, the repository does not provide one. And if your pipeline is Python-first with no Rust component, adding a Rust crate plus a binding is more moving parts than installing the Python Jieba, which the README itself lists indirectly by naming rjieba-py as the Python binding to this crate.
Alternatives and how their approach differs
The most direct alternative for Python users is the original Jieba, which the search data shows people look for alongside this project. The difference is not the algorithm, since jieba-rs is an implementation of it, but the runtime and the packaging: Jieba is pure Python with a dictionary shipped as data files, while jieba-rs compiles the dictionary into the binary via the default-dict feature and is consumed as a Cargo dependency. If you need to edit dictionaries at runtime without rebuilding, that difference matters.
For Rust search specifically, the README points at cang-jie, described as a Chinese tokenizer for tantivy, and tantivy-jieba, described as an adapter that bridges between tantivy and jieba-rs. These are not competitors so much as integration layers: they wrap this crate so a Tantivy index can use it as an analyzer. If your goal is a search index rather than a tokenizer in isolation, starting with one of those adapters saves you the wiring.
If you want to run segmentation in a browser or in a JavaScript runtime, the README lists jieba-wasm as the WebAssembly binding and @node-rs/jieba as the NodeJS binding. Both are separate repositories maintained by different authors, so their release cadence does not follow the crate's. The topics list on the repository includes wasm, which reflects that this is a supported use case rather than an afterthought.
Finally, the repository has a capi member in the workspace, which suggests a C API surface exists, but the README does not document it. Do not plan a C integration from the README alone.
Maintenance, licence and upgrade cost
The repository is not archived, and the last push was on 2026-09-15, the day before this article's reference point, so the project is receiving commits. The release history supports that: v0.10.1 on 2026-05-28, v0.10.2 on 2026-07-06, and v0.10.3 on 2026-07-19. Three patch releases in roughly two months is a normal maintenance rhythm for a library of this size.
The licence is MIT, stated in the README and in the workspace manifest, with a LICENSE file at the repository root. MIT is permissive: you can use the crate in closed-source software provided you keep the copyright notice and licence text. That is a summary of what the licence identifier means, not legal advice; read the LICENSE file before shipping.
Upgrade cost is low on the evidence available. The version has stayed in the 0.10 line across the recent releases, and the workspace pins jieba-rs and jieba-macros at 0.10.0 internally. The edition is 2024, so building from source requires a toolchain that supports it. The README's Rust 2015 note is the only compatibility caveat it mentions. Because the crate embeds a dictionary by default, an upgrade that refreshes that dictionary can change segmentation output for the same input, which is the one upgrade risk worth testing for: run your own corpus through cut before and after, rather than assuming patch releases are output-stable.
Editorial conclusion
Adopt jieba-rs if you are already writing Rust or need a Chinese tokenizer inside a Rust service, a Tantivy index, or a WASM bundle, and you want the MIT licence and the optional tfidf and textrank features. Do not adopt it if you want a command line tool or a server: the repository is a library workspace, and the README shows no CLI entry point. Before committing, verify two things: that the embedded default dictionary is the one you want, since default-dict is on by default and the README does not document how to swap it, and that you can reproduce the cut() output on your own text, because segmentation quality depends on the dictionary rather than on any tuning knob the README exposes.
Frequently asked questions
What is jieba-rs?
It is the Jieba Chinese word segmentation algorithm implemented in Rust, published on crates.io as jieba-rs. The README describes it in exactly that way and shows a Jieba::new() instance cutting a Chinese string into words.
How do I install jieba-rs?
Add jieba-rs = "0.10" to the dependencies section of your Cargo.toml. The README notes that on Rust 2015 you also need extern crate jieba_rs at the crate root.
Does jieba-rs support keyword extraction?
Yes, through two optional features. Enabling tfidf adds a TF-IDF keywords extractor and enabling textrank adds a TextRank keywords extractor, both configured in Cargo.toml as features = ["tfidf", "textrank"]. The README documents the flags but not the call sites.
Community notes