Convert Typst to TOML
Max file size 100mb.
Typst vs TOML Format Comparison
| Aspect | Typst (Source Format) | TOML (Target Format) |
|---|---|---|
| Format Overview |
Typst
Modern Typesetting System
Typst is a modern typesetting system launched in 2023 as a powerful alternative to LaTeX. It features clean markup syntax with = for headings, *bold*, _italic_, a built-in scripting language (#let, #set), and mathematical notation ($ ... $). Typst is written in Rust and compiles documents incrementally in milliseconds. Typesetting Modern |
TOML
Tom's Obvious, Minimal Language
TOML is a minimal configuration file format created by Tom Preston-Werner (co-founder of GitHub). Designed to be easy to read due to its clear semantics, TOML maps unambiguously to a hash table. It is the standard configuration format for Rust (Cargo.toml), Python (pyproject.toml), and many modern development tools. Configuration Minimal |
| Technical Specifications |
Structure: Plain text with Typst markup and scripting
Encoding: UTF-8 Format: Modern typesetting language Compiler: Typst CLI (Rust-based) Extensions: .typ |
Structure: Key-value pairs with sections
Encoding: UTF-8 (required) Standard: TOML v1.0.0 (2021) Processing: Parsed by language libraries Extensions: .toml |
| Syntax Examples |
Typst document with metadata: #set document( title: "Climate Modeling", author: "Prof. Ana Torres", date: datetime.today(), ) = Climate Modeling == Introduction Global climate models use *coupled* ocean-atmosphere simulations. - Temperature projections - Sea level estimates |
TOML structured data: # Document metadata from Typst [document] title = "Climate Modeling" author = "Prof. Ana Torres" date = 2026-03-12 [[sections]] title = "Introduction" level = 1 content = """ Global climate models use coupled \ ocean-atmosphere simulations.""" items = [ "Temperature projections", "Sea level estimates", ] |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2023 (Martin Haug & Laurenz Mager)
Written In: Rust License: Apache 2.0 Status: Active development, rapidly evolving |
Introduced: 2013 (Tom Preston-Werner)
TOML v1.0.0: January 2021 Status: Stable, finalized specification Adoption: Cargo, pip, Hugo, Netlify |
| Software Support |
Typst CLI: Official compiler (all platforms)
Typst App: Online collaborative editor VS Code: Tinymist extension Packages: Typst Universe registry |
Libraries: toml (Python), toml-rs (Rust), @iarna/toml
Editors: VS Code, IntelliJ, any text editor Validation: taplo (Rust-based linter/formatter) Tools: tomlq, dasel, taplo |
Why Convert Typst to TOML?
Converting Typst documents to TOML extracts structured metadata and content into the format preferred by the Rust ecosystem and modern development tools. Since Typst itself is written in Rust and uses TOML for its package manifests (typst.toml), there is a natural affinity between these two formats in the modern typesetting workflow.
TOML's unambiguous parsing and native date/time types make it ideal for representing document metadata. Unlike YAML, which can have surprising type coercions, TOML explicitly distinguishes between strings, integers, dates, and booleans. This precision is valuable when extracting publication metadata like dates, version numbers, and structured author information from Typst documents.
For static site generators like Hugo that use TOML configuration, converting Typst documents to TOML generates ready-to-use frontmatter blocks. Publication titles, authors, dates, abstracts, and tags can be automatically extracted and formatted as TOML for building academic portfolio sites and research blogs.
The conversion also supports Python's pyproject.toml ecosystem. Researchers who publish Python packages alongside their academic papers can extract metadata from Typst documents into TOML format for automated package configuration, documentation generation, and citation file creation (CITATION.cff via TOML intermediate).
Key Benefits of Converting Typst to TOML:
- Rust Ecosystem: Natural fit for Typst's Rust-based toolchain
- Unambiguous Types: No type coercion surprises (unlike YAML)
- Native Dates: TOML has first-class date/time support
- Comments Support: Annotate extracted data with explanatory notes
- Hugo Frontmatter: Generate config for static site builders
- Package Metadata: Extract for Cargo.toml or pyproject.toml workflows
- Formal Spec: TOML v1.0.0 ensures consistent parsing everywhere
Practical Examples
Example 1: Paper Metadata Extraction
Input Typst file (paper.typ):
#set document(
title: "Efficient Graph Algorithms",
author: ("Alice Chen", "Bob Williams"),
date: datetime(year: 2026, month: 3, day: 1),
)
= Efficient Graph Algorithms
== Abstract
We present novel algorithms for
large-scale graph processing with
sub-quadratic time complexity.
Output TOML file (paper.toml):
# Document metadata from Typst [document] title = "Efficient Graph Algorithms" authors = ["Alice Chen", "Bob Williams"] date = 2026-03-01 [abstract] content = """ We present novel algorithms for \ large-scale graph processing with \ sub-quadratic time complexity.""" [[sections]] title = "Abstract" level = 2
Example 2: Hugo Frontmatter Generation
Input Typst file (post.typ):
= Understanding Transformers
#let tags = ("deep-learning", "NLP", "attention")
The Transformer architecture introduced
by Vaswani et al. revolutionized NLP.
== Self-Attention
The core mechanism computes:
$ "Attention"(Q, K, V) =
"softmax"(Q K^T / sqrt(d_k)) V $
Output TOML file (post.toml):
# Hugo frontmatter from Typst title = "Understanding Transformers" date = 2026-03-12 tags = ["deep-learning", "NLP", "attention"] draft = false [content] summary = """ The Transformer architecture introduced \ by Vaswani et al. revolutionized NLP.""" [[sections]] title = "Self-Attention" level = 2
Example 3: Structured Data from Tables
Input Typst file (config.typ):
= Server Configuration
#let servers = (
(name: "web-01", port: 8080, region: "us-east"),
(name: "web-02", port: 8080, region: "eu-west"),
(name: "db-01", port: 5432, region: "us-east"),
)
#table(
columns: 3,
[*Name*], [*Port*], [*Region*],
..servers.map(s =>
(s.name, str(s.port), s.region)
).flatten()
)
Output TOML file (config.toml):
# Server Configuration from Typst [[servers]] name = "web-01" port = 8080 region = "us-east" [[servers]] name = "web-02" port = 8080 region = "eu-west" [[servers]] name = "db-01" port = 5432 region = "us-east"
Frequently Asked Questions (FAQ)
Q: What is TOML?
A: TOML (Tom's Obvious, Minimal Language) is a configuration file format created by GitHub co-founder Tom Preston-Werner. It uses a clear key = value syntax with [section] headers. TOML is the standard for Rust's Cargo.toml, Python's pyproject.toml, and Hugo's config.toml. Version 1.0.0 was finalized in 2021.
Q: Why TOML instead of YAML or JSON?
A: TOML offers unambiguous parsing (no surprising type coercions like YAML), native date/time types, comments support (unlike JSON), and a simpler specification. It is less indentation-sensitive than YAML and more human-readable than JSON. TOML is ideal when you need predictable, clearly-typed structured data.
Q: How does Typst relate to TOML?
A: Typst uses TOML for its own package manifest files (typst.toml) in the Typst Universe package registry. Both Typst and TOML share Rust heritage (Typst is written in Rust, TOML is standard for Rust's Cargo). This makes TOML a natural metadata format for the Typst ecosystem.
Q: Can I use the TOML output as Hugo frontmatter?
A: Yes. Hugo supports TOML frontmatter delimited by +++ markers. The converted TOML contains title, date, author, tags, and other metadata fields that Hugo expects. Simply wrap the TOML between +++ delimiters at the top of a content file for your Hugo site.
Q: How are Typst dates converted to TOML?
A: Typst's datetime() values map directly to TOML's native date type (e.g., 2026-03-12). TOML is one of the few data formats with first-class date/time support, making date conversion precise and unambiguous. No string quoting is needed for dates in TOML.
Q: How is multi-line content handled?
A: TOML supports multi-line strings using triple quotes ("""). Long text content from Typst paragraphs and abstracts is stored in multi-line basic strings with backslash line continuations. This preserves readability while maintaining proper TOML syntax.
Q: What about deeply nested Typst structures?
A: TOML handles nesting through [section] headers and dotted keys (e.g., document.metadata.title). However, TOML is intentionally less flexible than YAML for deep nesting. Complex hierarchical Typst structures are flattened appropriately, using arrays of tables ([[section]]) for repeated structures like sections and references.
Q: Can I convert TOML back to Typst?
A: Yes. Typst can read TOML data natively using its built-in toml() function. This enables round-trip workflows where document metadata is extracted to TOML, potentially modified, and then read back into Typst templates. This pattern is useful for generating documents from structured data sources.