# Mojo-toml v0.3.0 - Native TOML Parser

**URL:** <https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584>\
**Category:** Community Showcase\
**Created:** [January 7, 2026, 11:47pm UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584 "2026-01-07T23:47:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 7, 2026, 11:47pm UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584/1 "2026-01-07T23:47:42Z")

</div>

# mojo-toml v0.3.0 - Native TOML Parser

I’ve released **mojo-toml** , a native TOML 1.0 parser for Mojo with zero Python dependencies. Currently read-only.

## What it does

Parses TOML configuration files into native Mojo structures:

- All TOML 1.0 types (strings, integers, floats, booleans, arrays, tables)
- Nested structures with dotted keys
- Duplicate key detection
- Clear error messages with line/column context
- 96 tests ensuring reliability

## Installation

```bash
git clone https://github.com/DataBooth/mojo-toml.git
cd mojo-toml
pixi run test-all

```

Coming soon to the `modular-community` channel.

## Usage

```mojo
from toml import parse

fn main() raises:
    var config = parse("""
        [database]
        host = "localhost"
        port = 5432
    """)
    
    var db = config["database"].as_table()
    print(db["host"].as_string()) # "localhost"
    print(db["port"].as_int()) # 5432

```

## What’s in v0.3.0

- Proper dotted key support and duplicate detection
- Parser improvements with `reset()` method
- Reorganised test suite (96 tests across 10 files)
- Performance benchmarks and documentation

See the [CHANGELOG](https://github.com/DataBooth/mojo-toml/blob/main/CHANGELOG.md) for full details.

## Links

- [GitHub Repository](https://github.com/DataBooth/mojo-toml)
- [v0.3.0 Release](https://github.com/DataBooth/mojo-toml/releases/tag/v0.3.0)
- [Documentation](https://github.com/DataBooth/mojo-toml/blob/main/README.md)
- License: MIT

## Roadmap

Planned features for future releases:

- TOML writer (serialiser)
- Array of tables `[[array]]`
- Hex/octal/binary integers
- Native datetime parsing

## Acknowledgements

This project is sponsored by [DataBooth](https://www.databooth.com.au/posts/mojo), building high-performance data and AI services with Mojo.

Feedback and contributions most welcome!

---

<div class="post-metadata">

**Author:** ![owenhilyard](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/owenhilyard/32/41_2.png) [@owenhilyard](https://forum.modular.com/u/owenhilyard)\
**Post date:** [January 8, 2026, 3:14pm UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584/2 "2026-01-08T15:14:09Z")

</div>

Great foundational work for Mojo, thanks for this ecosystem contribution!

As always, I’ll encourage anyone writing Mojo libraries to add some benchmarks. We’ve had more than a few “accidentally faster than python’s SOTA” libraries.

---

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 9, 2026, 4:26am UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584/3 "2026-01-09T04:26:10Z")

</div>

Hi Owen - happy to add a benchmark- although this is a simple parsing package which should be sufficiently fast for real world use cases - will try and add a comparison with the Python package / Python standard lib in 3.11+

---

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 12, 2026, 1:59am UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584/4 "2026-01-12T01:59:45Z")

</div>

A more complete response 🙂

Thanks @owenhilyard! Great timing on the benchmark suggestion - **v0.5.0 now includes a comprehensive benchmarking system!** 🎯

We’re running both mojo-toml and Python’s `tomllib` (stdlib) on the same test cases with full machine specs:

```bash
pixi run benchmark-mojo # mojo-toml performance
pixi run benchmark-python # Python baseline

```

Both generate markdown reports in `benchmarks/reports/` with system info (CPU, GPU, RAM, Mojo/Python versions).

**Current results** (Apple M1 Pro):

- Real-world config files (pixi.toml): **~2ms** parse time
- Simple configs: **40K+ parses/sec**
- Python’s `tomllib` is currently **2-10x faster** (it’s implemented in optimised C)

Not “accidentally faster” yet 😄, but very competitive for a pure Mojo implementation. More importantly, it’s fast enough for the use case - config files parse in milliseconds, which is imperceptible for typical config loading. The focus has been on correctness, completeness, and usability rather than raw speed.

As Mojo’s compiler optimisations mature, I would expect to close the gap or exceed Python. Details in [PERFORMANCE.md](https://github.com/databooth/mojo-toml/blob/main/docs/PERFORMANCE.md) and the benchmark reports.

Would love to hear if there are specific performance-sensitive use cases we should optimise for or just specific performance tweaks as I am still very new to Mojo!

---

<div class="post-metadata">

**Author:** ![owenhilyard](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/owenhilyard/32/41_2.png) [@owenhilyard](https://forum.modular.com/u/owenhilyard)\
**Post date:** [January 14, 2026, 12:07am UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584/5 "2026-01-14T00:07:58Z")

</div>

Fantastic! I’m sure that with a little sprinkle of SIMD this could easily catch up (note that Mojo doesn’t do autovectorization, so your scalar code stays scalar).

The main use-case I would have for making this faster is parsing a lot of config files (think kubernetes amounts of config but in TOML). That’s almost pure drag racing, so it’s up to you if you want to go for it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [July 13, 2026, 12:08am UTC](https://forum.modular.com/t/mojo-toml-v0-3-0-native-toml-parser/2584/6 "2026-07-13T00:08:42Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
