tools / code converters / yaml-to-json

yaml-to-json

Convert YAML to JSON. Handles scalars, sequences, mappings, nested structures, comments, quoted strings, and multiline strings (literal | and folded >). No external dependencies - pure Node.js YAML parser.
Runs locally in your browser. Enable JavaScript to use the interactive tool. The practical details remain available below.

What yaml-to-json actually does

Most of the surprise in this conversion is type resolution, and most tools do not say which rules they follow. The word yes is a boolean under YAML 1.1 and a string under the 1.2 Core Schema. So is no, on and off. A value like 1:30 is a sexagesimal integer under 1.1 and a string under 1.2. Two converters can both be correct and disagree, and if neither names its schema the only way to find out is to be surprised by production. This one implements the 1.2 Core Schema and prints the rules in its help: only true and false in their three capitalizations are booleans; null, the tilde and an empty value are null; integers take a sign, 0x hexadecimal and 0o octal; floats take a leading point and an exponent with no point. Flow collections are the other common failure. Written inline in braces or brackets, the way a workflow file or a compose file usually writes them, they were until 2026-08-22 handed back as JSON strings by this tool: a mapping came out as the text of itself. They are parsed now, nested to any depth, and checked against a reference parser running in a separate process. A value that looks like a flow mapping but is not one, such as a Helm or Jinja template expression in double braces, is left as the string it is rather than mangled into an object.

How to use it

  • Paste the YAML, or drop a .yaml or .yml file on the left pane. It stays in this tab.
  • Press Convert, or cmd+enter.
  • Read the JSON on the right. It is editable, so a value can be corrected before it is copied anywhere.
  • Switch to Checks: the result is parsed again with JSON.parse, independently of the code that wrote it, and the line counts are printed.
  • Use Diff to see the structure change line by line.
  • Copy or download. Restore returns the parse exactly as it came out.

Useful for

  • Feed a workflow file, a compose file or a manifest to a tool that only reads JSON.
  • Find out why a configuration value is arriving as a string when you expected a boolean, by reading the schema rules this page states.
  • Check a hand-edited YAML file parses at all before committing it, and see the structure it actually produces.
  • Convert a fixture for a test suite that keeps its data in JSON.

Limits worth knowing

  • Anchors, aliases and merge keys are not resolved. An anchor is reported and left as a string.
  • Explicit tags are not honored; every scalar resolves under the Core Schema.
  • A multi-document stream is read as one document. Split it first.
  • Complex keys, the question-mark form, are not supported.
  • yes, no, on and off are strings here, deliberately. A tool implementing YAML 1.1 will give you booleans, and neither is wrong; the schema is the difference.
  • A value that opens with a brace but is not a well-formed flow mapping is kept as a string rather than guessed at, which differs from a strict parser that would refuse the document.

Questions people ask

undefined

undefined

undefined

undefined

undefined

undefined

undefined

undefined