Skip to main content

mozc-ffi

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

Build

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mozc-ffi 0.1.0
File Interpreter ABI Platform Actions
mozc_ffi-0.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for mozc_ffi-0.1.0-py3-none-win_amd64.whl
mozc_ffi-0.1.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for mozc_ffi-0.1.0-py3-none-manylinux_2_28_x86_64.whl

Total release size: 30.2 MB

Release files / mozc_ffi-0.1.0-py3-none-win_amd64.whl

Download URL mozc_ffi-0.1.0-py3-none-win_amd64.whl
Size 14.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
ab24ab1bfbe081a0684fc1b3b5cfd8b08dcae327ec880a1ab031bd40172dbafa
BLAKE2b-256 checksum
How to use checksums
86b5b8c0aa4b51b0a6d13772dffa246605d9cc6f01d38686d66b3c0c63ab797c
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 9, 2026.

Transparency log

Release files / mozc_ffi-0.1.0-py3-none-manylinux_2_28_x86_64.whl

Download URL mozc_ffi-0.1.0-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
5e325537832644390f1345bf70f4d4a4319beb7e4b39d968aca91f19dee6a77f
BLAKE2b-256 checksum
How to use checksums
3b66fc8d7701e554145d91cb372eefff2dd38a1c1e53c82e448c1a67e78913da
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 9, 2026.

Transparency log

Security for mozc-ffi 0.1.0

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.

Select from 2 files

Attestation for mozc_ffi-0.1.0-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 9, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page