Skip to content
UniKit

YAML to JSON converter

Convert YAML to JSON with multi-document support (--- separated, output as an array), anchors and << merge keys, automatic ISO conversion of dates, optional indentation and recursive key sorting, plus errors with exact line/column and structure statistics.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

YAML input

Supports multiple documents (--- separated → JSON array), anchors &name and << merge keys, and date timestamps (converted to ISO strings).

JSON

[
  {
    "defaults": {
      "host": "localhost",
      "port": 8080
    },
    "service": {
      "host": "localhost",
      "port": 9000
    },
    "created": "2020-01-02T03:04:05.000Z"
  },
  {
    "items": [
      {
        "name": "alpha",
        "enabled": true
      },
      {
        "name": "beta",
        "enabled": false
      }
    ]
  }
]

Structure

Documents2
Keys12
Arrays1
Scalars9
Depth3
Input lines14
Input bytes259
Dates (converted)1

Detected features

Anchors &Yes
Aliases *Yes
Merge keys <<Yes
Explicit tags !!No
Date timestampsYes

What this tool does

  • Convert Kubernetes, CI or Docker Compose YAML into JSON for scripts, template engines or API tools that only speak JSON.
  • See what the YAML actually parses into: dates become ISO strings and a bad indent reports the exact line and column instead of leaving you guessing.
  • Handle multi-document files (separated by ---) in one go — they come out as a JSON array instead of being pasted one by one.
  • Tick sort keys for stable output, so a code review does not produce a fake diff just because the key order changed.

Example

Input

name: UniKit
version: 1.2
stable: true
released: 2020-01-02
tags:
  - yaml
  - json

Output

{
  "name": "UniKit",
  "version": 1.2,
  "stable": true,
  "released": "2020-01-02T00:00:00.000Z",
  "tags": [
    "yaml",
    "json"
  ]
}

Output with the default options (2-space indent, no sorting, YAML 1.2 semantics). The unquoted 2020-01-02 is recognised as a date and becomes an ISO string in JSON; quote it as "2020-01-02" to keep the literal text.

Frequently asked questions

Why did my date become 2020-01-02T00:00:00.000Z?

The YAML timestamp tag turns an unquoted date into a time object, and JSON has no date type, so it has to be serialised as an ISO string in UTC. Quote the value to keep it as a string, or use whatever date format your consumers already expect.

How are multi-document files handled?

Documents separated by --- are parsed into a JSON array with one element each. A single document is emitted as-is unless you tick "always array", which wraps it. The document count in the stats panel reflects what was actually parsed.

Why did yes / no / on / off stay strings?

Parsing uses YAML 1.2 (Core schema) by default, where only true and false are booleans. Legacy configs use yes / no heavily, so the YAML 1.1 option makes those parse as booleans too and keeps you aligned with the original system.

What happens when the YAML is malformed?

You get the line, column and the reason reported by js-yaml (bad indentation, duplicated key, tab characters and so on) under the input box, not a generic "invalid format". Input beyond 500,000 characters is rejected with a too-long message.

Are anchors, merge keys and custom tags supported?

Anchors (&), aliases (*), merge keys (<<) and timestamps all parse correctly, and the features panel flags which ones your input uses. Values that JSON cannot represent degrade to number arrays or null rather than failing the whole conversion. Everything runs locally in your browser and is never uploaded.

Keywords:yamlymlyaml to jsonYAML 转 JSON合并键merge key锚点anchor多文档序列化

Related tools