typst-py
Python binding to typst, a new markup-based typesetting system that is powerful and easy to learn.
Installation
Requires Python 3.9 or newer.
pip install typst
Usage
import datetime
import typst
# Compile `hello.typ` to PDF and save as `hello.pdf`
typst.compile("hello.typ", output="hello.pdf")
# Compile `hello.typ` to PNG and save as `hello.png`
typst.compile("hello.typ", output="hello.png", format="png", ppi=144.0)
# Or pass `hello.typ` content as bytes
with open("hello.typ", "rb") as f:
typst.compile(f.read(), output="hello.pdf")
# Or return PDF content as bytes
pdf_bytes = typst.compile("hello.typ")
# Use a fixed creation timestamp for reproducible PDFs
timestamp = datetime.datetime.fromtimestamp(0, datetime.timezone.utc)
pdf_bytes = typst.compile("hello.typ", timestamp=timestamp)
# Also for svg
svg_bytes = typst.compile("hello.typ", format="svg")
# Typst 0.15 minifies PDF, SVG, and HTML by default; pass pretty=True for
# human-readable export output.
svg_bytes = typst.compile("hello.typ", format="svg", pretty=True)
# Multiple compatible PDF standards can be requested at once.
pdf_bytes = typst.compile("hello.typ", pdf_standards=["a-2a", "ua-1"])
# Skip PDF accessibility tags for smaller files, like the CLI's --no-pdf-tags.
# Tags cannot be disabled for PDF/A-1a, PDF/A-2a, PDF/A-3a, and PDF/UA-1.
pdf_bytes = typst.compile("hello.typ", pdf_tags=False)
# For multi-page export (the template is the same as the typst cli)
images = typst.compile("hello.typ", output="hello{n}.png", format="png")
# Or use Compiler class to avoid reinitialization
compiler = typst.Compiler()
compiler.compile(input="hello.typ", format="png", ppi=144.0)
# Query something
import json
values = json.loads(typst.query("hello.typ", "<note>", field="value", one=True))
# Or use Typst's newer eval-style query expression
values = json.loads(typst.eval("hello.typ", "query(<note>).first().value"))
Watch mode
Compiler.watch recompiles whenever the input or any file it depends
on (imports, images, data files) changes, like typst watch. Keep the output open in a
viewer next to your editor:
import typst
# Blocks until Ctrl-C. Compilation errors are printed and do not stop watching.
typst.Compiler("hello.typ").watch("hello.pdf")
It accepts the same output options as Compiler.compile.
Multi-file projects
You can compile multi-file Typst projects by passing a dictionary mapping filenames to
their content as bytes. The entry point must be keyed as "main" or "main.typ" (if
there is only one file, any key works):
import typst
files = {
"main.typ": b'#import "lib.typ": greet\n= Hello\n#greet("World")',
"lib.typ": b'#let greet(name) = [Hello, #name!]',
}
pdf = typst.compile(files, format="pdf")
This is useful when Typst sources are bundled as Python package resources:
import typst
import importlib.resources
files = {}
for filename in ["main.typ", "lib.typ", "utils.typ"]:
files[filename] = importlib.resources.read_binary("mypackage.typst_files", filename)
pdf = typst.compile(files, format="pdf")
Dictionary values can also be file paths (as strings or Path objects), which will be
read from disk.
Packages
Use package_path to point Typst at a local package directory and
package_cache_path to control where downloaded @preview packages are cached:
import typst
pdf = typst.compile(
"main.typ",
package_path="vendor",
package_cache_path="vendor",
)
Passing values
You can pass values to the compiled Typst file with the sys_inputs argument. For example:
import json
import typst
persons = [{"name": "John", "age": 35}, {"name": "Xoliswa", "age": 45}]
sys_inputs = {"persons": json.dumps(persons)}
typst.compile(input="main.typ", output="ages.pdf", sys_inputs=sys_inputs)
The following example shows how the passed data can be used in a Typst file.
#let persons = json(bytes(sys.inputs.persons))
#for person in persons [
#person.name is #person.age years old. \
]
License
This work is released under the Apache-2.0 license. A copy of the license is provided in the LICENSE file.
Metadata
Release files for typst 0.15.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| typst-0.15.2.tar.gz | 74.0 kB | Without provenance | Details for typst-0.15.2.tar.gz |
Built distributions (wheels)
Total release size: 668.6 MB
Release files / typst-0.15.2.tar.gz
| Download URL | typst-0.15.2.tar.gz |
|---|---|
| Size | 74.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4dad10ec2f209e19c2473bbaf294004d5cde885206a6b6c2a6bb5f6c1488e243
|
|
BLAKE2b-256 checksum How to use checksums |
a1f250d686fd982bd97d1fccd2b3424ed932165df59f75b32020041d1a85b640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-win_amd64.whl
| Download URL | typst-0.15.2-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 29.6 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
eb8ad3587e3f1c90a8ef2fd4d6f50d5a1f27d762b31faba6b91cee95fded5f8a
|
|
BLAKE2b-256 checksum How to use checksums |
3786fc60807fcdaeccdcb55a6898f9aceb8a2782c41757018ddbd923ea327675
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | typst-0.15.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 34.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ebdc708354082139da59893c5d6dbdd2b30970fbbf4396465756c7e62acfa33a
|
|
BLAKE2b-256 checksum How to use checksums |
7faac3263b08a060f3d9b346b6b544efba132652da0ab653df99c67a0996db34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl
| Download URL | typst-0.15.2-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl |
|---|---|
| Size | 35.8 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ IBM System/390x |
|
SHA-256 checksum How to use checksums |
36ec8e548bb77763eea79a3fab3982823fa99d5ce98bdcca7fa36888a8fe2015
|
|
BLAKE2b-256 checksum How to use checksums |
f14f1e94ee12a2b40514ffed11d24af9ac47b73dbd489e79127a1b0cb3460001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
| Download URL | typst-0.15.2-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl |
|---|---|
| Size | 36.9 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ PowerPC 64-le |
|
SHA-256 checksum How to use checksums |
f7a266427df5ca826ebf213e3bcc0b2dca8c43cb8256968f26daa325220a286d
|
|
BLAKE2b-256 checksum How to use checksums |
cf1d6a21a4d9997ee7160be5b123972ef6a37740d9a74df0f6995a45864b2f84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl
| Download URL | typst-0.15.2-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.whl |
|---|---|
| Size | 35.0 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARMv7l |
|
SHA-256 checksum How to use checksums |
56c78492487bc538edaaecc8b78d1d6f22d277ba0c142c01f64a58372fa28a27
|
|
BLAKE2b-256 checksum How to use checksums |
731edb663ff0e38bab5a0cec735c879981b99ce4ad2ad856d10db39a6f208fab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | typst-0.15.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 35.4 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
70393c16cd69912a37898716e8a20845ec996aeef0fb11b953126a00e698d881
|
|
BLAKE2b-256 checksum How to use checksums |
1b0ab473b52940c32fdfe92a71ec92ac34e8418064b7a7f36f5de0e0260a5d48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | typst-0.15.2-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 30.3 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
64b414e202fb9b02ad9be261bc66d472665f1d37ed65c72ab83f3fb14998faac
|
|
BLAKE2b-256 checksum How to use checksums |
356a3a8a2656f0c19dc0c5d9cb4ee1a578d27c4a5f151a73f277b9323634ac43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | typst-0.15.2-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 30.8 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d398cc614ae4a3c31499e5ba7e187739906fab00b14144d693208c74772aad76
|
|
BLAKE2b-256 checksum How to use checksums |
43d772f762c5c5ea0de2f8e1434e06cd6278dcf5f277307daa6486ff20f3f640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-win_amd64.whl
| Download URL | typst-0.15.2-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 29.6 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
98b69d80bf15ce36528b89e68a83a5af130071865f0bf96e24c118fa114592ec
|
|
BLAKE2b-256 checksum How to use checksums |
5869c30e8d8fdad3532f730a71f6f251028050f4c09d042da2d52123b73e21f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-pyemscripten_2026_0_wasm32.whl
| Download URL | typst-0.15.2-cp39-abi3-pyemscripten_2026_0_wasm32.whl |
|---|---|
| Size | 25.7 MB |
| Tags | CPython 3.9 PyEmscripten 2026.0+ WebAssembly abi3 |
|
SHA-256 checksum How to use checksums |
39f9320f7a07623e90b0a53cc5e913649cf381d2ff7e9293a5bc327831811a36
|
|
BLAKE2b-256 checksum How to use checksums |
e37753c6ccd53ded243954ad886af15133262bc88ad3ab8011840acc7849e35b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | typst-0.15.2-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 35.8 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8494e91a3d704baeff99257738c63f77ed49a5232fcfe3f8f813b9b3209a996e
|
|
BLAKE2b-256 checksum How to use checksums |
ada15046344d2a1767ef1af60303c2b23ab4035800f527a4b77ab73f13ae8e93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-musllinux_1_2_armv7l.whl
| Download URL | typst-0.15.2-cp39-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 35.3 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
ab55372ccc72082500b3d7ee0cd0346f36a50030e40ad9e253ea7e09b8c6f67a
|
|
BLAKE2b-256 checksum How to use checksums |
79863390d2775bb98633600a21c3636387a33c47571fb320a976d3ff7da002c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | typst-0.15.2-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 35.6 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d6a80c70014d185d4ba8cce7712ef8a20efb0451465008fd2d8846d71480f201
|
|
BLAKE2b-256 checksum How to use checksums |
1266c2db3e44904b88fcc15ced56e056a1d9df5b30dd68ef19f41e8e469f383c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | typst-0.15.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 34.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
99fe0916980cab453e60332125e133c737bf3b76efd325b60d055c551e5887a1
|
|
BLAKE2b-256 checksum How to use checksums |
0ae1699c7ed6c3719c7c302ba4fcd164cfadbbff8eccd0708830dc115f12dd7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl
| Download URL | typst-0.15.2-cp39-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl |
|---|---|
| Size | 35.8 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
eecc84a47f665f33fcae3923af35f1bac39c10d15f655146bfc5b3d310adcb1a
|
|
BLAKE2b-256 checksum How to use checksums |
4f1e0364b836c7d54d435693321da37e12fcd0cd181ccd125977bcdea3c17d24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
| Download URL | typst-0.15.2-cp39-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl |
|---|---|
| Size | 36.9 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
c18b97875072123534fb86455794c7b534deaa1b61dae8fb9b93e0e083a9eff6
|
|
BLAKE2b-256 checksum How to use checksums |
23de9b330e26e61146468f075746b6d5139a301db59e0b815abd4e1723c4cb3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.whl
| Download URL | typst-0.15.2-cp39-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.whl |
|---|---|
| Size | 35.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
9f168900b4a089cf8be40e07c52fb1ad99e628a71343fb2424255f2891c75bca
|
|
BLAKE2b-256 checksum How to use checksums |
b3c5c56c194fa08eb9815d6cab230de1a466bf40a3a3e9254a3c3b5ee7d01dc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | typst-0.15.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 35.5 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
11c6f06b47dd0e3448720d120ab79dd488b83a5c525f66133f8ebc6f909404b1
|
|
BLAKE2b-256 checksum How to use checksums |
5a65c609ad773e9ea4bf0183fd3f39d7a7b81f86f56206a8578bcb673d145d79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | typst-0.15.2-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 30.4 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
19d77c2eb4c423f2517f585ce7876bd4fc96d9c2355985c7b1e0943c1b3c4541
|
|
BLAKE2b-256 checksum How to use checksums |
342236e0a357dd4cd984edd5c5dfa99cf01753a59839012b3e20edddae8e95b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Release files / typst-0.15.2-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | typst-0.15.2-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 30.8 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d6d8a9c7700202fdd8488ffbcbe959d3f730590905bfbbfdcbb781e1c403e923
|
|
BLAKE2b-256 checksum How to use checksums |
eef9fd7670f5a802ea314a11479be32409cae473230a5fce5ad54b5141bb4cc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.16.0
|
Security for typst 0.15.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.