.NET bindings for Typst, the modern markup-based typesetting system.
Typst.Native lets you compile Typst documents to PDF, SVG, and PNG directly from .NET — no CLI installation or external processes required.
- Native performance: calls Typst's Rust core via P/Invoke (no WASM overhead)
- Cross-platform: ships pre-built native libraries for Windows, Linux, and macOS (x64 + ARM64)
- Zero external dependencies: everything is bundled in the NuGet package
- Idiomatic C# API:
TypstCompiler, diagnostics, streaming output
dotnet add package Typst.Nativeusing Typst.Native;
using var compiler = new TypstCompiler();
var result = compiler.Compile("Hello, *Typst* from .NET!");
if (result.IsSuccess)
{
byte[] pdf = result.ToPdf();
File.WriteAllBytes("output.pdf", pdf);
}
else
{
foreach (var diag in result.Diagnostics)
Console.Error.WriteLine(diag);
}| Runtime | NuGet RID | CI Runner |
|---|---|---|
| Windows x64 | win-x64 |
windows-latest |
| Linux x64 | linux-x64 |
ubuntu-latest |
| Linux ARM64 | linux-arm64 |
ubuntu-24.04-arm |
| macOS x64 | osx-x64 |
macos-latest (cross-compile) |
| macOS ARM64 | osx-arm64 |
macos-latest |
- .NET 8.0 SDK or later
- Rust toolchain (stable)
cd native/typst-ffi
cargo build --releaseThe shared library will be output to native/typst-ffi/target/release/.
dotnet build
dotnet testNote: To run tests locally, you need to first build the native library and place it in the appropriate
runtimes/{rid}/native/directory undersrc/Typst.Native.Runtime/.
Typst.Native/
├── native/typst-ffi/ # Rust FFI crate — thin C API over Typst
├── src/
│ ├── Typst.Native/ # Managed C# wrapper (main NuGet: Typst.Native)
│ ├── Typst.Native.Runtime/ # Native binaries package (Typst.Native.Runtime)
│ └── Typst.Native.Tests/ # Unit & integration tests
└── .github/workflows/ # CI/CD pipelines
| Package | Description |
|---|---|
Typst.Native |
Managed wrapper — the package you reference |
Typst.Native.Runtime |
Pre-built native libraries for all platforms |
Contributions are welcome! Please open an issue first to discuss what you'd like to change.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes
- Push to the branch and open a Pull Request
This project is licensed under the MIT License.
Typst itself is licensed under the Apache License 2.0. See the Typst repository for details.