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.
- 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
Download the latest .mltbx file from Releases. Open the file, or install programmatically:
matlab.addons.toolbox.installToolbox("MATLAB_Toolbox_for_TOML_and_YAML.mltbx")% 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;% 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");readyaml- Read YAML filewriteyaml- Write YAML fileyamldata- Creatematlab.io.config.YAMLDatadatatypematlab.io.config.YAMLData- Struct-like datatype for YAML
readtoml- Read TOML filewritetoml- Write TOML filetomldata- Creatematlab.io.config.TOMLDatadatatypematlab.io.config.TOMLData- Struct-like datatype for TOML
See toolbox/doc/GettingStarted.mlx for an introductory walkthrough, or explore the toolbox/examples/ folder:
YAML Examples:
readyamlExample.m- Reading YAML fileswriteyamlExample.m- Writing YAML filesyamlWorkflowExample.m- End-to-end read/modify/write workflow
TOML Examples:
readtomlExample.m- Reading TOML fileswritetomlExample.m- Writing TOML filestomlPyprojectExample.m- Working withpyproject.toml
Demo Scripts:
conversionExample.m- Converting between structs, dictionaries, containers.Map, and data objects
This toolbox implements a simplified YAML parser optimized for configuration files. It is not a full YAML 1.2 compliant parser.
- YAML: Subset parser. See readyaml documentation for details on supported/unsupported features (anchors, tags, etc.). Being addressed in the cpp-parser-serializer branch.
- MATLAB R2022b or later (for
dictionarywith value semantics) - No additional toolboxes required
Copyright 2026 The MathWorks, Inc. See license.txt for details.
See CONTRIBUTING.md for guidelines on building source code, submitting issues, and pull requests.
