Skip to content

Repository files navigation

MATLAB Toolbox for TOML and YAML

The MATLAB® Toolbox for TOML and YAML adds support for reading and writing YAML and TOML configuration files with very strong round-trip support. The toolbox includes custom data types that make it easier to work with YAML and TOML data than structures or tables. The implementation is pure MATLAB with no third-party dependencies.

MATLAB Toolbox for TOML and YAML

Open in MATLAB Online View on File Exchange

Features

  • YAML & TOML Support - Read and write both formats with consistent interface
  • Dot Notation Access - Natural MATLAB syntax: config.database.host
  • Special Characters - Handle keys with hyphens, spaces: config.("build-system")
  • Full Round-Trip - Read, modify, write back without data loss
  • Implicit Type Conversion - Automatic conversion to optimal MATLAB types
  • Flexible File Writing - Control formatting, indentation, array styles

Installation

Download the latest .mltbx file from Releases. Open the file, or install programmatically:

matlab.addons.toolbox.installToolbox("MATLAB_Toolbox_for_TOML_and_YAML.mltbx")

Quick Start

Reading Files

% Read YAML
config = readyaml("server_config.yaml");
host = config.database.host;

% Read TOML
project = readtoml("simple_project.toml");
name = project.project.name;

% Keys with special characters
deps = project.("build-system").requires;

Writing Files

% Create data
config = yamldata();
config.name = "MyApp";
config.database.host = "localhost";
config.database.port = 5432;

% Write YAML
writeyaml(config, "my_config.yaml");

% Write TOML
writetoml(config, "my_config.toml");

Main Functions

YAML

TOML

Examples

See toolbox/doc/GettingStarted.mlx for an introductory walkthrough, or explore the toolbox/examples/ folder:

YAML Examples:

TOML Examples:

Demo Scripts:

  • conversionExample.m - Converting between structs, dictionaries, containers.Map, and data objects

Limitations

This toolbox implements a simplified YAML parser optimized for configuration files. It is not a full YAML 1.2 compliant parser.

Requirements

  • MATLAB R2022b or later (for dictionary with value semantics)
  • No additional toolboxes required

License

Copyright 2026 The MathWorks, Inc. See license.txt for details.

Contributing

See CONTRIBUTING.md for guidelines on building source code, submitting issues, and pull requests.


About

TOML and YAML readers, writers, and datatypes for MATLAB.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages