Skip to content
YAS.SH
Developer🌐 YAS server-sideAPI availableintermediate

TOML / JSON Converter

Converts between TOML and JSON — TOML is common in modern config files (Cargo, pyproject, Go).

Processed by YAS · not stored
Ready to runInstant execution
All tools →
Loading tool…

What does this tool do?

Converts between TOML and JSON — TOML is common in modern config files (Cargo, pyproject, Go).

Why would I use it?

  • You need a JSON version of a Cargo.toml or pyproject.toml for a tool.
  • You want to inspect a TOML file's structure quickly.
  • You are migrating config between formats.

Real-life example

Input
[server]
host = "127.0.0.1"
port = 8080
Output
{"server":{"host":"127.0.0.1","port":8080}}

TOML tables become nested JSON objects.

Input → Process → Output → Next

Input
Paste TOML or JSON.
Process
YAS parses and converts between the two.
Output
The converted document.
Next action
Check arrays-of-tables and datetime values converted correctly.

Common mistakes

  • Missing the [table] headers that define nesting.
  • Using tabs for indentation (TOML forbids tabs inside values).
  • Expecting comments to survive (they do not).

What the result means

The output mirrors the TOML structure as JSON objects, arrays and scalars.

Privacy & security

Your input is sent to YAS infrastructure because the tool requires server-side processing or public network queries. Input is not stored.

API

Endpoint
POST https://yas.sh/api/v1/tools/toml-json
Request Header
Content-Type: application/json
cURL
curl -X POST "https://yas.sh/api/v1/tools/toml-json" \
  -H "Content-Type: application/json" \
  -d '{"input":"name = \"Jane\"\nage = 30","mode":"to-json"}'
JavaScript
const res = await fetch("https://yas.sh/api/v1/tools/toml-json", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "input": "name = \"Jane\"\nage = 30",
  "mode": "to-json"
}),
});
const data = await res.json();
Python
import requests

r = requests.post("https://yas.sh/api/v1/tools/toml-json", json={"input":"name = \"Jane\"\nage = 30","mode":"to-json"})
data = r.json()
FieldTypeRequiredDescription
inputstringYesTOML or JSON text
modestringNo (default to-json)to-json | to-toml
Success response
{ "result": { "name": "Jane", "age": 30 }, "mode": "to-json" }

Convert between TOML and JSON (mode: to-json | to-toml).

Error responses
  • 400 VALIDATION_ERROR — invalid input or unsupported option.
  • 413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.
  • 429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).
Limits
  • Maximum input: 64 KB per request.
  • Rate limit: 60 requests/min per IP address.
  • Authenticated accounts benefit from higher tier quotas.

TOML / JSON Converter: technical reference, use cases and FAQ

How TOML / JSON Converter works

TOML is parsed according to the v1.0.0 specification into the same kind of tree JSON produces — tables become objects, arrays become arrays, and scalars become strings, integers, floats, booleans or dates. Converting to JSON is then a direct serialization of that tree. The reverse direction walks a JSON value and emits TOML tables, promoting nested objects to [table] or [[array.of.tables]] headers where that produces more readable output.

The formats are not isomorphic, and the gaps matter. TOML has first-class date-times (offset, local, date-only and time-only) that JSON can only represent as strings; TOML distinguishes integers from floats while JSON has a single number type; and TOML forbids null entirely, so a JSON null has no landing place and is dropped or must be represented by omitting the key.

When to use it: real-world scenarios

Reading a Cargo.toml or pyproject.toml programmatically

Converting to JSON lets you query the manifest with jq or any JSON library in a CI script, without adding a TOML parser dependency.

Migrating configuration between formats

Projects moving from JSON config to TOML for comments and readability can convert the existing file rather than retyping it and introducing typos.

Debugging how a TOML table nests

Dotted keys and [[array of tables]] syntax are the two things people get wrong. Seeing the JSON equivalent removes the ambiguity instantly.

Generating TOML from a script

Emitting JSON from code and converting is often simpler than templating TOML by hand, especially for arrays of tables.

Pro tips

  • Everything after a table header belongs to that table until the next header. A key placed below a [table] you did not intend to extend is the classic TOML bug.
  • Quote keys containing dots, or they become nested tables: a.b = 1 creates table a with key b, while "a.b" = 1 creates a single key named a.b.
  • TOML has no null. Represent absence by omitting the key and letting your application supply the default.
  • Multi-line basic strings (triple quotes) preserve newlines; literal strings (single quotes) disable escape processing, which is what you want for Windows paths and regex patterns.

Limitations and edge cases

What this tool deliberately does not do, and where it will disagree with other implementations.

  • JSON null has no TOML equivalent and cannot round-trip.
  • TOML date-time types degrade to strings in JSON, losing the type distinction on the way back.
  • Comments are not preserved in either direction — both parsers discard them, so converting a commented config loses the commentary.
  • The integer/float distinction is lost through JSON, so 1 and 1.0 may not survive a round trip unchanged.

Frequently asked questions

Are comments preserved when converting?
No. Comments are discarded during parsing, in both directions. Keep the commented original in version control and treat the conversion as a derived artefact.
How are TOML dates represented in JSON?
As ISO 8601 strings, because JSON has no date type. Converting back produces a string unless you re-annotate the value, so date types do not survive a round trip.
What happens to null values from JSON?
TOML v1.0.0 has no null. The key is omitted rather than given a placeholder, since inventing one would silently change the meaning of the config.
Which TOML version is supported?
v1.0.0, the current stable specification. Documents relying on pre-1.0 draft syntax may parse differently or fail.
Ask YAS AI
🍪 Cookies & privacy. Essential cookies keep you signed in and remember language and theme. Google AdSense and reCAPTCHA are Google technologies: AdSense runs only after Accept All; reCAPTCHA loads on sign-in and contact forms. See how Google uses data: https://policies.google.com/technologies/partner-sites cookie policy · privacy policy.
Settings