How do I convert YAML to JSON?
A YAML to JSON converter translates configuration between YAML, JSON and TOML. This YAML to JSON converter detects the input format, reports syntax errors with line numbers and can sort keys, and your config never leaves the browser.
Configuration files come in three common formats: YAML for Kubernetes and CI, JSON for APIs and TOML for tools such as Cargo and pyproject. They describe the same kinds of data, so converting is mostly a matter of syntax, but each format has quirks that trip up hand edits.
Paste any of the three and the tool detects it, then writes the others. Syntax errors are reported with the line number, and you can sort keys alphabetically so two files can be compared. Parsing uses the yaml and smol-toml libraries loaded on demand.
Conversion can lose things that one format has and another lacks: YAML comments and anchors do not survive in JSON, and TOML requires a table at the top level and has its own date types. Check the output before you commit it.
Page updated .
How to use the YAML, JSON and TOML Converter
- Paste YAML, JSON or TOML.
- Check the detected format and fix any reported error.
- Choose the target format and copy or download the result.
Examples
name: app port: 8080
{"name":"app","port":8080}{"title":"x","owner":{"name":"Ada"}}title = "x" and a [owner] table with name = "Ada"
Tips
- Sort keys before diffing two configs so ordering noise disappears.
- YAML is indentation-sensitive: use spaces, not tabs.
- Quote YAML values such as
no,onand1.10if they must stay strings.
Specs & limits
- Formats
- YAML, JSON, TOML
- Libraries
- yaml (ISC) and smol-toml (BSD-3-Clause)
- Options
- Auto-detect, sort keys
- Errors
- Reported with line numbers
- Processing
- In your browser
Troubleshooting
›Parse error at a line
Cause: Indentation or quoting problem.
Fix: Check the line shown and use spaces.
›TOML rejects null
Cause: TOML has no null.
Fix: Remove or replace those keys.
›Output differs from the original
Cause: Comments and anchors are lost.
Fix: Keep the original for comments.
Frequently asked questions
›Are YAML comments kept when converting?
No. JSON and TOML output cannot carry YAML comments, and YAML comments are dropped on conversion.
›Why did my version number change?
An unquoted 1.10 in YAML is read as the number 1.1. Quote it to keep a string.
›Can TOML represent every YAML structure?
No. TOML needs a table at the top level and does not allow null values.
›How are errors shown?
With a message and line number so you can find the problem.
›Does it handle multiple YAML documents?
The converter works with a single document.
›Is my config uploaded?
No. Conversion runs in your browser.