mozc-ffi
English | 日本語
Unofficial C API and bindings for Mozc, Google's open-source Japanese
kana-kanji converter. Mozc runs inside your process, with its dictionary built in: no mozc_server, no IPC, no
install. Not affiliated with Google.
Every call is self-contained. You pass a reading and, optionally, segment lengths and the text before it, and get
back segments with candidates. Picks you learn rank first next time.
core/ |
The C API (mozc_ffi.h) and its implementation over Mozc's converter |
bindings/python/ |
Python bindings (ctypes, one module) and tests |
bindings/csharp/ |
C# bindings (netstandard2.0, works in Unity) and tests |
bindings/rust/ |
Rust bindings (the mozc-ffi crate) and tests |
bindings/node/ |
Node.js bindings (koffi, with TypeScript types) and tests |
scripts/ |
The build scripts, check.sh (every lint check and test), the pinned Mozc commit (MOZC_COMMIT) |
tests/ |
chat.tsv, everyday chat sentences used by every test suite, and smoke.c, a C program using the API |
Install
Each package comes with the library already built, for Linux x64 (glibc 2.28 or later) and Windows x64.
| Install | Needs | |
|---|---|---|
| Python | pip install mozc-ffi |
Python 3.11+ |
| C# | dotnet add package MozcFfi |
.NET Standard 2.0 |
| Node.js | npm install mozc-ffi |
Node.js 22+ |
| Rust | cargo add mozc-ffi |
Rust 1.88+, and the library (below) |
| C | An archive from Releases |
The Rust crate holds only the bindings, because the library is larger than crates.io allows. Download the archive for
your platform from Releases and either put libmozc_ffi.so or
mozc_ffi.dll next to your executable, or set MOZC_FFI_LIBRARY to its path.
The archives hold the header, the library and, on Windows, the import library. SHA256SUMS lists their checksums.
Build
To build the library yourself instead: both scripts fetch Mozc at the commit in scripts/MOZC_COMMIT into build/mozc and build core/ inside its source
tree. The first build downloads Mozc's dependencies and takes a while. Everything built lands in build/, so deleting
it is a full clean.
Linux needs Bazelisk, Git and GCC:
scripts/build.sh # → build/libmozc_ffi.so
Windows needs Bazelisk, Git, Python 3.12+, Visual Studio 2022 or 2026 with the C++ tools and C++ ATL, and Developer
Mode. Build from a clone on a Windows drive (not \\wsl.localhost):
.\scripts\build.ps1 # → build\mozc_ffi.dll
The DLL links the C++ runtime statically, so it needs no Visual C++ Redistributable.
Use
from mozc_ffi import Mozc
with Mozc("/path/to/profile") as mozc:
mozc.convert("ここではきものをぬぐ", [3, 5, 2]) # [Segment("ここで", [...]), Segment("はきものを", ["履物を", ...]), ...]
mozc.predict("ありがと") # ["ありがとう", ...]
mozc.learn("かんじ", [3], ["感じ"]) # 感じ ranks first next time
using var mozc = new MozcFfi.Mozc(profileDir);
var segments = mozc.Convert("きょうはさむいですね"); // segments[0].Candidates[0] == "今日は"
mozc.Learn("かんじ", new[] { 3 }, new[] { "感じ" });
let mozc = mozc_ffi::Mozc::open(Some(Path::new("/path/to/profile")), false)?;
let segments = mozc.convert("ここではきものをぬぐ", &[3, 5, 2], "");
mozc.learn("かんじ", &[3], &["感じ"], "");
const { Mozc } = require('mozc-ffi');
const mozc = new Mozc('/path/to/profile');
mozc.convert('ここではきものをぬぐ', [3, 5, 2]);
mozc.learn('かんじ', [3], ['感じ']);
mozc.close();
Each binding loads the library when it opens Mozc: from MOZC_FFI_LIBRARY, next to the program (or package), or the
system's library path. It stays loaded until the process exits.
Segment lengths count Unicode characters. Mozc keeps the profile directory per process, so open one profile per
process. incognito learns nothing.
Test
scripts/check.sh # every lint check, then every test
scripts/check.sh lint python # one lint check: c, python, csharp, rust, node, scripts
scripts/check.sh test rust # one binding's tests: c, csharp, python, node, rust
The tests use the library in build/. CI runs the same commands on Linux and Windows for every pull request.
Releases
Releases are made by release-please from conventional-commit PR titles; .github/RELEASING.md has the steps.
Licence
BSD-3-Clause. The built library contains Mozc and its dictionary, whose licences are in THIRD_PARTY_NOTICES.md.
Metadata
Release files for mozc-ffi 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mozc_ffi-0.1.1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for mozc_ffi-0.1.1-py3-none-win_amd64.whl |
| mozc_ffi-0.1.1-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for mozc_ffi-0.1.1-py3-none-manylinux_2_28_x86_64.whl |
Total release size: 30.2 MB
Release files / mozc_ffi-0.1.1-py3-none-win_amd64.whl
| Download URL | mozc_ffi-0.1.1-py3-none-win_amd64.whl |
|---|---|
| Size | 14.8 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1e413fc46a29f1efa5e1bf7d69690b9319238b75bbc8324b7b420420362d22d5
|
|
BLAKE2b-256 checksum How to use checksums |
a839cc2a51cc4624e0dd0ddd10703cc8505f880f2af4484b56eef1420aa6e1bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / mozc_ffi-0.1.1-py3-none-manylinux_2_28_x86_64.whl
| Download URL | mozc_ffi-0.1.1-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 15.4 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
8c600b3d841a30e0a9a93a11ae6463c2e9edf648e67144c30a1e2ccef5db97ad
|
|
BLAKE2b-256 checksum How to use checksums |
6cea634994f3d96aeb9da7a6440591ce640dd3ba16442e3b478dbd19056f0186
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logSecurity for mozc-ffi 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mozc_ffi-0.1.1-py3-none-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.