Back to Tools

YAML to JSON Converter

Parse YAML documents and convert to structured JSON with hierarchy preservation

🔗 Nested Support📋 Arrays & Objects
YAML Input

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

  1. 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.
  2. Choose an Indentation of 2 spaces, 4 spaces or Minified.
  3. Tick Sort Keys if you want object keys in alphabetical order at every level.
  4. Press Convert to JSON.
  5. 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








Frequently Asked Questions

Why do I get an error for a file with several documents?
The tool parses a single YAML document. If your file has multiple documents separated by lines of three dashes, the parser reports an error. Paste each document separately and convert them one at a time.
Are YAML comments preserved?
No. JSON has no comment syntax, so comments are discarded during conversion. Anchors and aliases are also expanded, meaning repeated blocks appear in full in the JSON output. This applies at every depth of the document.
Why did my value become true or null instead of text?
YAML infers types from unquoted values, so true, false, null and numbers are treated as those types. To keep them as strings, wrap the value in quotes in the YAML before you convert, for example "2.1.0" or "yes". Quotes tell the parser to treat the value as text.
Does Sort Keys affect arrays?
No. It orders the keys of objects alphabetically at every depth, but the order of array items stays as written, since the sequence in a list usually carries meaning. Sorting is applied only when the checkbox is ticked.
Does it work offline?
Not without the library. The conversion depends on js-yaml, loaded from a public CDN when the page opens. If it is blocked or you are offline, the converter cannot parse YAML until the script is available.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.