YAML to JSON Converter
Parse YAML documents and convert to structured JSON with hierarchy preservation
Turn YAML configuration into JSON
YAML is comfortable for people to write, but scripts, APIs and many validators want JSON. This converter reads YAML pasted into the box and outputs the equivalent JSON. It uses the js-yaml library, which the page loads from a CDN, so the page needs to be able to reach that script to convert.
Using it
- Paste your YAML into YAML Input, press Paste to bring it from the clipboard, or press Sample to load an application config with app, server, database and features sections.
- Choose an Indentation of 2 spaces, 4 spaces or Minified.
- Tick Sort Keys if you want object keys in alphabetical order at every level.
- Press Convert to JSON.
- Copy the output or press the JSON button to save output.json.
A badge above the result reads Valid YAML on success, and the stats bar shows the number of top-level keys and the output size in bytes. If parsing fails, the badge shows the parser's message and the result box begins with a YAML Error line, which normally includes the line and column of the problem.
What conversion does to YAML features
- Comments are dropped because JSON has no way to store them.
- Anchors and aliases are resolved, so repeated content is written out in full.
- Values are typed following YAML rules: unquoted true becomes a boolean, 8080 becomes a number, and quoted numbers such as the version 2.1.0 remain strings.
- Lists become arrays and mappings become objects, nested to any depth.
Typical situations
- Checking what a Kubernetes, Docker Compose or CI file looks like as data before feeding it to a script.
- Producing JSON test fixtures from YAML examples in documentation.
- Converting OpenAPI fragments to JSON for tools that do not accept YAML.
- Debugging indentation issues by seeing how a file is actually interpreted.
Limitations
The tool loads a single YAML document. A file containing several documents separated by three-dash lines will produce an error, so convert them one at a time. Indentation must use spaces, since YAML forbids tabs for nesting. Unquoted values that resemble other types, such as yes, no, null or dates, may be interpreted as those types, and dates come out as timestamp strings in JSON. Quote the value in the YAML if you need it kept as text.
Related Articles
Related Tools