JSON to TOML
Convert a JSON object into TOML.
POST
1 credit
/v1/convert/json-to-toml
curl -X POST "https://convert.toolkitapi.io/v1/convert/json-to-toml" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"data": {"server": {"host": "localhost", "port": 8080}}}'
import httpx
resp = httpx.post(
"https://convert.toolkitapi.io/v1/convert/json-to-toml",
json={"data": {"server": {"host": "localhost", "port": 8080}}},
)
print(resp.json())
const resp = await fetch("https://convert.toolkitapi.io/v1/convert/json-to-toml", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({"data": {"server": {"host": "localhost", "port": 8080}}}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response
200 OK
{
"toml": "[server]\nhost = \"localhost\"\nport = 8080\n"
}
Description
Convert a JSON object into TOML.
How to Use
1
1. POST a JSON body with `data` set to a JSON object.
2
2. Read the `toml` string from the response.
About This Tool
Converts a JSON object to TOML — the configuration format used by Cargo, pyproject.toml, and many Rust/Python tools.
Top-level primitive arrays and values are supported, but TOML requires a table structure at the root, so the input must be a JSON object.
Why Use This Tool
- Cargo.toml / pyproject.toml — Generate Rust or Python project files from JSON templates
- Config migration — Move JSON configs into TOML-native tools
- Documentation — Render config examples in TOML for readers
- Template exports — Produce TOML artifacts in build pipelines
Frequently Asked Questions
Must the root be an object?
Yes — TOML requires a top-level table structure.
Are nested objects supported?
Yes — nested objects become TOML tables (`[parent.child]`).
What about arrays of objects?
TOML arrays of tables (`[[foo]]`) are emitted for arrays where every element is an object.
Start using JSON to TOML now
Get your free API key and make your first request in under a minute.