JSON to YAML / TOML Converter
Convert JSON to YAML or TOML and back in real time. Type in either panel and see the other update instantly. Handles nested objects, arrays, null values, and preserves data types correctly.
JSON to YAML / TOML Converter
Bidirectional converter between JSON, YAML, and TOML. Type in either panel and see the other update instantly.
How to Use the JSON to YAML / TOML Converter
A platform engineer needs to convert a Terraform variables file from JSON to YAML format for use in an Ansible playbook. Paste the JSON into the left panel, select YAML as the output format, and click JSON to YAML. The converted YAML appears instantly in the right panel. Copy the output and paste it into your Ansible playbook. The round-trip capability lets you verify accuracy by pasting the YAML back and converting it to JSON to confirm no data was lost.
A developer setting up a Python project needs to convert existing package configuration from JSON to TOML format for pyproject.toml. Paste the JSON configuration, select TOML as the output format, and click JSON to TOML. The converter groups nested objects into TOML table sections and object arrays into array-of-tables sections, producing valid TOML that Poetry or PDM can consume directly.
A DevOps engineer receives a Kubernetes ConfigMap in JSON format from an API but needs to paste it into a YAML-based Helm chart. Paste the JSON, select YAML, and click convert. The YAML output uses block-style formatting with 2-space indentation, which is the standard convention for Kubernetes manifests. Copy the result directly into your values.yaml file.
A Rust developer has a JSON configuration file but wants to use TOML because it is the standard for Cargo. Paste the JSON, select TOML, and click convert. The converter handles nested tool sections correctly, producing valid TOML with table headers and dotted keys. Verify the output by pasting it back into the JSON panel and confirming the round-trip produces identical data.
An integration engineer bridges two systems that use different serialisation formats. JSON input from one API can be converted to YAML for a CI/CD pipeline, or TOML configuration from a Rust application can be converted to JSON for analysis in a JavaScript monitoring dashboard. The bidirectional conversion supports both directions without requiring separate tools.
How the Format Converter Works
You paste JSON into the left panel and need YAML or TOML on the right. The tool first validates your input with JSON.parse(), then walks the resulting object tree recursively to emit the target format. Each format has its own rules for quoting strings, nesting objects, and representing arrays.
JSON to YAML: Block-Style Output with Minimal Quoting
The YAML serialiser uses 2-space indentation and block-style formatting. Strings are only quoted when they contain characters that YAML could misinterpret, such as colons or leading whitespace. Arrays use hyphen-prefixed lines, and nested objects are indented beneath their parent key. This produces clean, readable YAML suitable for Kubernetes manifests, Ansible playbooks, and CI/CD configuration files where the convention is block-style YAML.
JSON to TOML: Tables and Array-of-Tables
TOML groups keys into three categories: scalar values become top-level key-value pairs, nested objects become bracketed table sections like [database], and arrays of objects become double-bracketed array-of-tables sections like [[users]]. This structure matches how Cargo (Rust), pyproject.toml (Python), and other TOML-based tools expect their configuration. Strings are double-quoted, and inline arrays of primitives use comma-separated brackets.
Reverse Conversion: YAML/TOML Back to JSON
For reverse conversion, a format-specific parser tokenises the input using regex-based rules with indentation tracking for YAML and table-header detection for TOML. The parser builds a nested JavaScript object, which is then serialised to JSON via JSON.stringify(). This round-trip lets you verify accuracy by converting back and forth and comparing the results.
Frequently Asked Questions
What happens to JSON null values during TOML conversion?
TOML does not have a null type, so null values are simply omitted from the output. If your JSON has a field set to null, that key will not appear in the TOML output. If you need to preserve the presence of the key, set it to an empty string or a default value before converting.
Can the converter handle circular references in JSON?
No. Circular references are not representable in JSON, YAML, or TOML as standard formats. If your JSON input contains a circular reference, JSON.stringify() will throw a TypeError during the initial parsing step. You need to break the cycle in your data before converting it.
Why are some YAML keys quoted in the output?
YAML has special syntax for colons, hashes, leading whitespace, and numeric patterns. The converter wraps any key that contains these characters in double quotes to prevent YAML parsers from misinterpreting them. For example, a key like 2024-01 would be treated as a number without quotes, so it gets quoted to preserve it as a string key.
Is the TOML output compatible with Cargo and pyproject.toml?
For standard structures, yes. The converter generates valid TOML v1.0 for flat objects, nested tables, and arrays of tables. Simple package configurations, dependency lists, and tool settings convert cleanly. Complex TOML features like inline tables within arrays or dotted keys on table headers are not fully supported, so verify the output against your tool's validator if you run into issues.
How do I check that the conversion did not lose data?
Paste the output back into the converter in reverse mode. After converting JSON to YAML, paste the YAML into the right panel and click YAML to JSON. If the round-tripped JSON matches the original input, the conversion is accurate. Minor whitespace differences do not affect the data, so compare the parsed objects rather than the raw text.