TOML
Convert TOML 1.0 documents to JSON and JSON objects to TOML. Typical uses: read or write a configuration file.
toml to_json <toml>
Description
Read a TOML text or file (a one-line argument without = and [ is a path, with the usual rights on files; 32 MB at most). Returns the JSON text. The error names the line
Read a TOML text or file (a one-line argument without = and [ is a path, with the usual rights on files; 32 MB at most). Returns the JSON text. The error names the line
Parameters
toml: The TOML text or a file - String - required
toml: The TOML text or a file - String - required
admin
toml to_json "title = \"Demo\" [server] host = \"127.0.0.1\" port = 8080 ratio = 0.5 start = 2026-11-05T10:00:00Z [[users]] name = \"a\" [[users]] name = \"b\""
mentdb
{"title": "Demo", "server": {"host": "127.0.0.1", "port": 8080, "ratio": 0.5, "start": "2026-11-05T10:00:00Z"}, "users": [{"name": "a"}, {"name": "b"}]}
a key defined twice
admin
toml to_json "a = 1 a = 2"
mentdb
ERROR: Sorry, an error appears (TOML line 2: the key 'a' is already defined).
json to_toml <json>
Description
Write a JSON object as TOML
Write a JSON object as TOML
Parameters
json: The JSON object - String - required
json: The JSON object - String - required
admin
json to_toml "{\"title\": \"Demo\", \"server\": {\"host\": \"127.0.0.1\", \"port\": 8080}, \"users\": [{\"name\": \"a\"}, {\"name\": \"b\"}], \"tags\": [\"x\", \"y\"]}"
mentdb
title = "Demo" tags = ["x", "y"] [server] host = "127.0.0.1" port = 8080 [[users]] name = "a" [[users]] name = "b"
json to_toml <json> <params>
Description
Write with parameters: dates (false; true: the texts that are dates are written as TOML dates), nulls (error or skip)
Write with parameters: dates (false; true: the texts that are dates are written as TOML dates), nulls (error or skip)
Parameters
json: The JSON object - String - required
params: The parameters as JSON - String - required
json: The JSON object - String - required
params: The parameters as JSON - String - required
admin
json to_toml "{\"day\": \"2026-11-05\", \"at\": null}" "{\"dates\": true, \"nulls\": \"skip\"}"
mentdb
day = 2026-11-05
