Skip to main content

Python binding to Typst, a new markup-based typesetting system that is powerful and easy to learn.

Project description

typst-py

CI PyPI Documentation Status

Python binding to typst, a new markup-based typesetting system that is powerful and easy to learn.

Installation

pip install typst

Usage

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")

# Also for svg
svg_bytes = typst.compile("hello.typ", format="svg")

# 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))

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typst-0.14.9.tar.gz (63.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

typst-0.14.9-cp314-cp314t-win_amd64.whl (21.6 MB view details)

Uploaded CPython 3.14tWindows x86-64

typst-0.14.9-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (26.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

typst-0.14.9-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl (27.2 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ s390x

typst-0.14.9-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (28.4 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ppc64le

typst-0.14.9-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (27.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARMv7l

typst-0.14.9-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (27.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

typst-0.14.9-cp314-cp314t-macosx_11_0_arm64.whl (22.8 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

typst-0.14.9-cp314-cp314t-macosx_10_12_x86_64.whl (23.1 MB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

typst-0.14.9-cp38-abi3-win_amd64.whl (21.7 MB view details)

Uploaded CPython 3.8+Windows x86-64

typst-0.14.9-cp38-abi3-pyemscripten_2026_0_wasm32.whl (18.4 MB view details)

Uploaded CPython 3.8+PyEmscripten 2026.0 wasm32

typst-0.14.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (26.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

typst-0.14.9-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (27.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ s390x

typst-0.14.9-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (28.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ppc64le

typst-0.14.9-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (27.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARMv7l

typst-0.14.9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (27.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

typst-0.14.9-cp38-abi3-macosx_11_0_arm64.whl (22.8 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

typst-0.14.9-cp38-abi3-macosx_10_12_x86_64.whl (23.1 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file typst-0.14.9.tar.gz.

File metadata

  • Download URL: typst-0.14.9.tar.gz
  • Upload date:
  • Size: 63.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for typst-0.14.9.tar.gz
Algorithm Hash digest
SHA256 53a7ee0825c127c100023685eeb8fb911226d7ad9ae861a370c11bb0f5c160cc
MD5 179c292be7dcec46b51054a2e528b7fd
BLAKE2b-256 4677b4856939057e0007d5399b9d425545a729708714dc0de4e5028c79c94539

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: typst-0.14.9-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 21.6 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for typst-0.14.9-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 b5637861645b0abb2529e1006a8984a831ecd9d24610a60e99d3ae0af4e4691a
MD5 35c93710d4f46f07744c35091cb7bac4
BLAKE2b-256 818ebe9ab684001336f1bae61022204521041151036f5d8a5365c34a29ec727c

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eabac1449c75381828996eaf352bfd795857668834a4c9cc6308d7687352ed49
MD5 0638674c5d34fb07ea5bfbcbe7a8d8a0
BLAKE2b-256 f82344249884d2aebdc01d66c9c5ecdd99f79547615ab32247e4f243c2ab6d94

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 a67963bd4e3b6969eee412a2bf49753276cd95be0acc86c07fd0c06f188a41bc
MD5 9ea28acac464df0ab8a9f5448d0afbc1
BLAKE2b-256 c30ebe73406f081fc6a2ae3e96e7dc7c3c983e43b3f92db16f753dd90b3cc65f

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 456ecf0e9bf02748fb3d7b6f0176aff36027ee8c2e81056eca20b3d4ba54e82b
MD5 a5dd8ba42167c57ca41cf2be07d13213
BLAKE2b-256 963e4af0a0f84030f19438d54e2d1b8f37a8c5e1cad83b9f58ee40ac83d05699

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 d2676e5b6548ae83b13ff3b769f5f30cf5d716b712502ea64a8e98fc3ae4577f
MD5 a9d9c674f58f7f4a829075237328e75e
BLAKE2b-256 60b126e98492703ff20b4b5cd2515f6f3d5881a85c76414f557cdd5088043f14

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3f054414502fd21b84474bdd1c92263be1910e010a5a6bdb0d546d7a00131f91
MD5 a0a0983913c6b5efa00cb55970ba50ed
BLAKE2b-256 dc983ab10001e57d38a20d3cd74e9060e1103a069265c881f5b4dab3a906f9e2

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3d62e29ce38c45e94e81716383c153272438964b76c343b9a2183fe52a9ff02
MD5 771ceec0bf767d903b6290e2a21c01a0
BLAKE2b-256 66819860be782781c43956e71cc9dbdb5f79207de56b4400d8266bf91a993e07

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp314-cp314t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 abc1348393390173ba7b993389b06b3df4b635cf69205aedaa05ce51de9be3b6
MD5 cc283f1b4c07c752de15de4db4224a22
BLAKE2b-256 a6dc340783f8514d776314408201a48b187ce8f7fc63896b3da895faf5e7c200

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: typst-0.14.9-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 21.7 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for typst-0.14.9-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6ebe6b433f71e9ec03c444b26f123363ab63ebab9a289fc4f26d6962b18fad4e
MD5 6d0fd26b0869eefc793859fda5d325a9
BLAKE2b-256 50d133d71cc89dc66e5a703a980ccee3217c8486a156a4e57fe7897b4097ce90

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-pyemscripten_2026_0_wasm32.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-pyemscripten_2026_0_wasm32.whl
Algorithm Hash digest
SHA256 2f7008b41217194a41b9eec611cef358cc7c8d90193817b182f9abed62526984
MD5 835f93390d39c2e8126bed9e0c5e321d
BLAKE2b-256 84eae0cc7e8eb1872db3aa68f297b940e55a8b16487e09a518cfc069cf749453

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 be26d1f195b75d4c57e7411646124f8257d136417cc5e9c393dcd8ea3c3a11e8
MD5 05aab21bcc7fc0b26a85fe06fa3a1ec1
BLAKE2b-256 d3663ac1d2001495ce81d9f26a25287f728664eb3bf6845c3a9bae7ea22a050e

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 7be2e851ee3ff3561c79d244a2809089fb7cfc678912555ecabb031d5de74da9
MD5 43cfdbd1bb93de3868365a7ff0b71b56
BLAKE2b-256 4c496e43f443bcf137a27d0622e6a12147ad4255cefd20f1e59d2b895b5c3192

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c4ecc5102125880baebbe454946a8492f6377680bf3d74f60650fae093958e3b
MD5 88b56dc4230e681ac35501fbb6b567f2
BLAKE2b-256 eeda0045f3ce468a5b17551b2de2a5dc17338e8ab39e8d9c9171ee4ccf20cc0a

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 792818bb147ea4a88b0555fd2066e1bb0b65353aecd01270a8acd3be018f3e39
MD5 fd18d157ac030ee86b876f57f3599fd6
BLAKE2b-256 7bca6b948b617de32fba14c036f141ee5c2ec8f3c282bbc7001663203c312afe

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1339a1d8beb05f098090a8a6c627e1aa7d4c7792b333e59694d30072f6f0ccdb
MD5 a320818dbc6a97cb7eb06f0c8d8e518d
BLAKE2b-256 d71ffaf63f411c6e3fee8b7540ce0e666fea06fd338e81115880ad0889dd0de4

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ade0c99e853bf02bcc28f1bad8be3714de5ee5323e1a0f649abdb4e634240e9
MD5 c68ac376d583f956c876eeea8346450f
BLAKE2b-256 842415f5e9ba7ecfea955a0311410e51a8c7990f9167e4fe0f98c7755e4c9580

See more details on using hashes here.

File details

Details for the file typst-0.14.9-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for typst-0.14.9-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4c4404891b3c8bfbb01d9e9308a24b9637088fb41aea0f24b58a9dffdd43b164
MD5 eb51af0f227bdb38e7c53debf88a77f0
BLAKE2b-256 882010ab263e9d52f6ca717e682ea4ac301204cb41be3bf08974d9513d52033f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page