Skip to main content

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/unity/ The Unity package's own files (package.json and .meta files); scripts/package.sh adds the C# bindings and the library
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 and arm64 (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
Unity The com.malorn44.mozc-ffi package (below) Unity 2021.3+, Windows or Linux x64
Node.js npm install mozc-ffi Node.js 22+
Rust cargo add mozc-ffi --features download Rust 1.88+
C An archive from Releases

The Rust crate holds only the bindings, because the library is larger than crates.io allows. Its download feature fetches the library from this version's release when building, and checks its SHA-256 (it needs curl and tar):

cargo add mozc-ffi --features download

To ship your program, copy the library (mozc_ffi::DOWNLOADED_LIBRARY) next to your executable. Without the feature, 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.

For Unity, add npm as a scoped registry and the package to your project's Packages/manifest.json, next to what is already there. The package holds the C# bindings and the library, and later versions show up in the Package Manager:

{
  "scopedRegistries": [
    { "name": "npm", "url": "https://registry.npmjs.org", "scopes": ["com.malorn44"] }
  ],
  "dependencies": {
    "com.malorn44.mozc-ffi": "0.2.0"
  }
}

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.

A call that can't do what was asked returns nothing (an empty list, or false); last_error then says why, in English, without ever quoting what was typed.

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.2.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.2.0
File Interpreter ABI Platform Actions
mozc_ffi-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for mozc_ffi-0.2.0-py3-none-win_amd64.whl
mozc_ffi-0.2.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for mozc_ffi-0.2.0-py3-none-manylinux_2_28_x86_64.whl
mozc_ffi-0.2.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for mozc_ffi-0.2.0-py3-none-manylinux_2_28_aarch64.whl

Total release size: 45.4 MB

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

Download URL mozc_ffi-0.2.0-py3-none-win_amd64.whl
Size 14.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
09bc68321ac6cf1d361ef686dd84c54c57646e9234526c8b4a413a8d912274ac
BLAKE2b-256 checksum
How to use checksums
acb52b16044f546c9e9444abdd8e50511f9cc6b282f4d087779473a2dfe2298c
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 log

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

Download URL mozc_ffi-0.2.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
408a98814ff4e8a3605e1dbc89c50a7e55650111df2d783ce67f12f4131400ef
BLAKE2b-256 checksum
How to use checksums
a8bcead0a44a4a70c7b8bb1ce09c17fd4316d48821f5b7dd7381d9255b5f4cb0
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 log

Release files / mozc_ffi-0.2.0-py3-none-manylinux_2_28_aarch64.whl

Download URL mozc_ffi-0.2.0-py3-none-manylinux_2_28_aarch64.whl
Size 15.3 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
f6edbbdb3f1e353a010f450b36949236adc7b17707293383ab664773582aed4c
BLAKE2b-256 checksum
How to use checksums
334ecba1a0850f45f9bf5430fc5242d6486b95e2e17ad9d8bc7c4e0399bccc9a
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 log

Security for mozc-ffi 0.2.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

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for mozc_ffi-0.2.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 10, 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