Formats & Conversion
JSON, YAML and TOML: compare the same configuration
Convert one configuration across three formats, verify its structure and identify null, date, number and comment losses.
Start with the format required by the consuming application. If it expects JSON, a more readable YAML file is not a compatible replacement until the pipeline explicitly converts and validates it.
The same configuration in three formats
Download config.json, then try JSON to YAML and JSON to TOML. These versions describe the same nested data:
{"name":"api-gateway","port":8080,"featureFlags":["rate-limit","audit-log"],"database":{"host":"localhost","poolSize":20}}
name: api-gateway
port: 8080
featureFlags:
- rate-limit
- audit-log
database:
host: localhost
poolSize: 20
name = "api-gateway"
port = 8080
featureFlags = ["rate-limit", "audit-log"]
[database]
host = "localhost"
poolSize = 20
In TOML, featureFlags belongs before [database]. Keys written after that header belong to the database table until another table header changes the context. Moving that array below the header would produce database.featureFlags, changing the configuration even though parsing succeeds.
Convert back with YAML to JSON or TOML to JSON. Check port is a number, featureFlags is at the root, and database.poolSize is 20. Formatting and key order may differ without changing these values.
Differences that affect a round trip
Scroll horizontally to see all columns.
| Input feature | What to check |
|---|---|
JSON null |
TOML has no direct null value; inspect conversion warnings |
| JSON root array | TOML documents are tables; wrapping changes the shape |
| YAML aliases / cyclic references | Repeated values may expand; cycles cannot be ordinary JSON trees |
| YAML non-string map keys / custom tags | Not all values have a portable JSON equivalent |
| TOML dates and times | JSON has no native date type; string conversion loses type information |
| Large integers or non-finite floats | JavaScript precision and valid JSON number limits apply |
| Comments and formatting | Standard JSON does not preserve either as metadata |
The JSONCraft converter warns about some unsupported TOML values, including nulls and root arrays. A warning is a reason to inspect the data contract, not proof that the replacement is equivalent.
A practical choice
Choose JSON for interchange when broad support and a strict data model matter. Choose YAML when the surrounding toolchain uses it and human annotations or its additional syntax are useful. Choose TOML for configuration that fits its tables and explicit scalar types. Human-edited JSON remains sensible when the application requires it and editors provide validation.
YAML behavior depends on version and parser options. YAML 1.1 may interpret NO as false; YAML 1.2 narrowed boolean spelling. Tags and merge-key support also vary. Do not assume that a browser conversion proves another runtime’s loader has identical semantics. Use a safe loader for untrusted YAML and validate the result.
TOML arrays permit trailing commas; JSON does not. TOML inline tables have their own rules, so state which TOML version your parser supports instead of treating all punctuation rules as interchangeable.
Keep secrets out of examples and feedback forms. The converter processes input locally, while hosting and optional measurement follow the privacy policy.
References: JSON RFC 8259, YAML 1.2.2 specification, and TOML 1.0 specification.
Related tools
Frequently asked questions
Can every JSON value be represented in TOML?
No. TOML has no null value, and its document root is a table. A converter may warn, replace unsupported values or wrap a root array; inspect its output.
Are comments preserved through JSON?
No. Standard JSON has no comments. A parse-and-emit conversion also need not preserve YAML anchors or original formatting.