JSON tools
JSON vs YAML vs TOML: Choose a Configuration Contract
Compare JSON, YAML and TOML using equivalent settings, explicit value types and round-trip checks, including comments, nulls and dates.
Choose a format your application actually supports
JSON, YAML and TOML can all represent common configuration settings, but they do not have identical syntax or data models. The first decision is which formats the consuming application supports. A preference for fewer braces does not justify converting a file that the application only reads as JSON.
For an HTTP data exchange, JSON is often convenient because the participating applications already parse it. For a hand-maintained configuration, comments and a layout suited to nested settings may matter more. Treat these as project requirements, then test the selected parser and configuration loader together.
Represent one small configuration three ways
This example describes a fictional local service. The name is text, the port is an integer, enabled is a boolean, and tags is an ordered list of strings. None of the examples contains a password or a real deployment endpoint.
{"service":{"name":"catalog","port":8080,"enabled":true,"tags":["local","test"]}}
service:
name: catalog
port: 8080
enabled: true
tags:
- local
- test
[service]
name = "catalog"
port = 8080
enabled = true
tags = ["local", "test"]
Parse the documents with the corresponding implementations and compare the service object, not the displayed line count. All three should give the same four settings and value types for this restricted example. A conversion that changes enabled to the string "true" has altered the contract even if the result remains syntactically valid.
Make type differences part of the decision
The JSON specification has a small set of values and no comment syntax. The YAML 1.2.2 specification describes scalars, sequences and mappings with additional presentation features. The TOML 1.0 specification defines configuration-oriented tables and typed values, including dates and times.
Do not assume every value has a direct equivalent in all three. JSON null needs an intentional policy when moving to TOML: omit an optional setting if the application defines omission that way, or choose an explicitly documented representation. Replacing null with an empty string silently changes the value and can be wrong.
Dates need the same care. A quoted date is text, while a parser may recognize an unquoted date-like value as a date object in a format supporting that type. Decide whether the application needs a textual identifier, a local date or an instant with an offset. Then create a fixture that proves the loader returns that intended type.
Evaluate how people will edit the file
For a service with two shallow sections, TOML table headers can make ownership obvious. For a deeply nested deployment structure, a team may prefer YAML's indentation, provided its linting and parser conventions are explicit. For machine-generated exchange data, JSON's limited syntax can reduce the number of format-specific features authors need to understand.
Comments are useful to explain why a setting exists, but ordinary conversion through an in-memory data object may discard them. Retain the human-maintained source separately if comments carry operational knowledge. Do not overwrite that source with a converted file merely because the values matched.
Agree on duplicate-key handling, parser versions and formatting rules. An ambiguous input accepted by one library and rejected by another is a portability issue. Include a deliberately duplicated key in a negative fixture and require the behavior your project documents.
Test a migration with more than the happy path
Start with the four-field example, then add your real edge cases one at a time: empty strings, empty arrays, a name with a colon, a multiline message and a large identifier represented as a string. Preserve array order. Check the saved output by loading it with the actual application, not only with the converter.
The local JSON to YAML page can exercise the JSON and YAML versions. It is not a TOML converter. For a TOML migration, use the application's documented TOML parser and compare the resulting configuration values against the expected object.
The browser converter uses a bounded JSON-compatible subset. It reports unsupported dates, non-finite values and precision-changing numbers instead of silently substituting another value. Quoting an identifier is appropriate when the contract defines a string; quoting an actual numeric measurement merely to bypass a rejection changes its type and needs a separate application decision.
Keep a reviewed original and a rollback path during the migration. A successful parser run establishes readable syntax; a successful application check establishes that the supported keys, types and defaults still produce the intended configuration.


