toml++ ships as one toml.hpp or a regular include tree, and its parser can be compiled out with a single define
Header-only TOML config file parser and serializer for C++17.
At a glance
- What is it?
- marzer/tomlplusplus is a TOML parser and serializer for C++17 that you can drop in as one header. This piece covers the two ways to include it, the package managers it names, the preprocessor switches and the gaps in its release history.
- Who is it for?
- Use toml++ when a C++17 project needs TOML 1.0.0 parsing and serialization and you want to add it by copying toml.hpp or through Conan, vcpkg, Meson or CMake FetchContent. Look elsewhere if you are stuck below C++17 or need a library whose releases are recent: the newest tag is v3.4.0 from October 2023.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 3 days ago.
- What is it written in?
- Mainly C++, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- marzer/tomlplusplus2,189 ★ · +24
| Repository | 2026-10-09 | 2026-11-25 |
|---|---|---|
| marzer/tomlplusplus | 2.2k | 2.2k |
24 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Copying toml.hpp into the tree is the whole single-header install
toml++ comes in two flavours, Single-header and Regular, and the API is the same in both. For the single-header route the instructions have two steps: drop toml.hpp wherever you like in your source tree, and then there is no step two. The repository root carries that file next to include/, so you can pull it from a checkout or from a release.
The feature list calls the library "Header-only (optional!)". The optional part is the Regular flavour, which keeps the headers split under include/ and lets you compile parts of the library separately if you want to. Either way the code you write does not change. You include the same header and call the same functions, so you can start with the single file and move to the include tree later without touching your own sources.
The regular flavour needs include paths and, for modules, one extra define
The Regular flavour starts with a clone of the repository. Then you add tomlplusplus/include to your include paths. If you want the optional module support, you also add tomlplusplus/modules and enable TOMLPLUSPLUS_BUILD_MODULES. After that you write #include <toml++/toml.hpp>, or import tomlplusplus; when modules are on.
Module support is listed as a library feature, and the repository has a modules/ path referenced in these steps, but the instructions give no compiler version list for modules specifically. The tested floor in the feature list is Clang 8 and up, GCC 8 and up, and MSVC from VS2019. Whether your toolchain handles import tomlplusplus; is something you confirm in your own build, since the instructions only name the define and the extra include path.
Nine ways to pull it in, with exact versions for Conan and DDS only
Beyond the two flavours, the install section names Conan, DDS, Tipi.build, Vcpkg, Meson, CMake FetchContent and Git submodules. Only some of them fix a version. Conan takes tomlplusplus/3.4.0 in your conanfile, DDS takes 'tomlpp^3.4.0' in package.json5, and the FetchContent block pins GIT_TAG v3.4.0.
Vcpkg and Meson do not pin anything in the instructions:
vcpkg install tomlplusplusmeson wrap install tomlplusplusAfter the wrap, you use it as a regular dependency with dependency('tomlplusplus'), or add it directly as a subproject. Tipi.build wants an entry for marzer/tomlplusplus in .tipi/deps, and Git submodules use git submodule add --depth 1 with the repository URL. The consequence is that vcpkg and Meson give you whatever version their registries carry, so check which one you got before relying on a feature.
Six defines decide what gets compiled and how much it costs
Configuration happens through preprocessor defines that you set before including toml++. The author says you probably will not need them, and the table backs that up with defaults that work out of the box. A few are worth knowing because they change build cost.
TOML_ENABLE_PARSER and TOML_ENABLE_FORMATTERS both default to 1. Set either to 0 and you improve compile times and binary size, which matters if you only read config files or only write them. TOML_ENABLE_UNRELEASED_FEATURES defaults to 0 and turns on support for TOML language features that have not been released. TOML_ASSERT(expr) swaps the assert function, defaulting to assert(), and TOML_CONFIG_HEADER includes a header of your choosing before the rest of the library.
TOML_DISABLE_CONDITIONAL_NOEXCEPT_LAMBDA exists for one case: MSVC's legacy lambda processor. If you are on that toolchain and hit noexcept errors, that is the switch the table points at. The table continues past what is reproduced here, including TOML_ENABLE_WINDOWS_COMPAT, which handles conversion between wide and narrow strings.
Reading a file is parse_file plus value_or on a chained subscript
The basic usage example parses a configuration.toml with a library table and a dependencies table. The C++ side starts with toml::parse_file( "configuration.toml" ), then reads values by subscripting: config["library"]["name"].value_or(""sv). The same pattern reaches into arrays, as in config["library"]["authors"][0], and into integers, as in config["dependencies"]["cpp"].value_or(0) for an int64_t.
Value_or means a missing key hands back your fallback instead of throwing, so a typo in a key name silently returns the default. Editing is shown with insert_or_assign("alternatives", toml::array{ "cpptoml", "toml11", "Boost.TOML" }), which inserts an array naming three other TOML libraries. Iteration over mixed data uses config.for_each with a generic lambda taking a key and a value. More code lives in the examples directory, which holds simple_parser.cpp, toml_merger.cpp, toml_generator.cpp, error_printer.cpp, parse_benchmark.cpp and toml_to_json_transcoder.cpp.
It supports TOML 1.0.0 and serializes to JSON and YAML, not just TOML
The library targets the latest TOML release, v1.0.0, plus optional support for unreleased TOML features behind the define described above. It passes all tests in the toml-test suite. UTF-8 is handled properly, including the BOM, and the library does not require RTTI. It works with or without exceptions, which matters for embedded and game codebases that compile with exceptions off.
Output is not limited to TOML. The library supports serializing to JSON and YAML as well, and the examples directory includes a toml_to_json_transcoder.cpp program. That makes it a candidate when one tool has to read TOML and emit JSON.
The tested matrix covers Clang 8 and up, GCC 8 and up, MSVC in VS2019, and the x64, x86 and ARM architectures. Anything outside that list, such as an older GCC, is untested territory, and the language floor is C++17, with some C++20 features used where available, for example experimental support for char8_t strings.
The newest release is v3.4.0 from October 2023, and the homepage carries the real docs
The release list shows v3.4.0 on 2023-10-13, v3.3.0 on 2023-01-29 and v3.2.0 on 2022-08-29. The repository itself saw a push on 2026-07-21 and is not archived, so work continues on the branch, but no tag has followed v3.4.0. If you pin by release, you get the 2023 code, and every pinned example in the install section uses 3.4.0.
The README tells readers directly that it is fine but the homepage at marzer.github.io/tomlplusplus is better. Full API documentation and many specific snippets live there, and the README example is described as favouring brevity. That example is also cut off in the text available here, so treat the homepage as the reference for anything beyond parse_file and value_or.
On dependencies, a consumer has none. Test-related dependencies matter only if you work on the library, and CONTRIBUTING.md covers them. The author also says he is not up to speed with every packaging option and welcomes pull requests that add new ones.
Editorial conclusion
Use toml++ when a C++17 project needs TOML 1.0.0 parsing and serialization and you want to add it by copying toml.hpp or through Conan, vcpkg, Meson or CMake FetchContent. Look elsewhere if you are stuck below C++17 or need a library whose releases are recent: the newest tag is v3.4.0 from October 2023. Check your compiler against the tested floor of Clang 8, GCC 8 and VS2019 before committing.
Frequently asked questions
How do I install toml++ in a C++ project?
Drop toml.hpp into your source tree, or use Conan with tomlplusplus/3.4.0, vcpkg install tomlplusplus, meson wrap install tomlplusplus, CMake FetchContent with GIT_TAG v3.4.0, or a git submodule. The API is the same for the single-header and regular flavours.
Does toml++ need exceptions or RTTI?
No to both. It works with or without exceptions and does not require RTTI. It targets C++17 and is tested on Clang 8+, GCC 8+ and MSVC from VS2019.
Can toml++ write JSON or YAML?
Yes. It supports serializing to JSON and YAML, and the examples directory contains a toml_to_json_transcoder.cpp program.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/marzer-tomlplusplus)Star history chart for your README
[](https://hysenlabs.com/projects/marzer-tomlplusplus)Was this useful?