YAML to JSON

Paste or upload YAML to convert it into JSON. Anchors are rejected.

Pasted text and chosen files stay on this device. Nothing is sent to a server.

Drop a file here, choose one, or paste.

No output yet Convert to see the result here.

How to use it

  1. 1

    Paste the YAML, or upload a .yaml / .yml file.

  2. 2

    If the output is JSON, download or copy it. If it is an error, the message names the line and column of the unsupported feature.

What it does

This converter handles block mappings and sequences, flow {} and [], and comments. It does not expand anchors or aliases, apply merge keys, or keep tags. If the document uses one of those, you get an error at the line and column where it appeared.

Parse the YAML and emit JSON when the document stays inside the supported subset. If an anchor, alias, merge key or tag is present, return an error that names the feature and the line and column, and do not emit JSON.

Why it works this way

JSON has no anchors, aliases, merge keys or tags. Expanding or dropping them quietly would invent or lose a value, so this tool refuses the document and points at the first unsupported token.

Ordinary mappings, lists and scalars convert directly. That is the subset this page is for: a settings file or a list of records that does not use YAML's reference machinery.

A position in the error is what makes the refusal usable. An error that only says 'unsupported' leaves you searching the file; line and column tell you which token to remove or rewrite.

Examples

title: hello
count: 3
{
  "title": "hello",
  "count": 3
}
a mapping of scalars converts directly
a: &x 1
b: *x
error at line 1 column 4: anchors and aliases are not supported
the anchor is refused, and the error points at &x rather than copying the value

Inputs and outputs

  • YAML text
  • JSON text
  • or an error naming the unsupported feature, with line and column

Edge cases

  • multiple documents in one file
  • anchors, aliases, merge keys and tags — refused, with the position of the first one
  • tabs in indentation — an error in YAML
  • duplicate keys

Frequently asked questions

Why did it reject my anchors?

This converter does not expand anchors or aliases. JSON has no references, and copying values silently would hide that the document used them. Remove the anchors, or use a full YAML processor, if you need that feature.

Does it apply merge keys or keep tags?

No. A merge key or an explicit tag is also refused, with the line and column of the first one found.

Related tools

Sources

  • YAML 1.2 specification, sections 3.2.2 and 6.9 (Anchors, Aliases, Tags)