multi-document aware · manifest to json

YAML to JSON for Kubernetes — the API server's view

Cluster config lives in YAML, and half the tooling wants JSON. Convert a manifest — multi-document file and all — and see the exact JSON the API server would receive.

Converter — Ready
Awaiting input
idle — paste YAML and the JSON shows up here
0 keys 2-space indent
runs entirely in your browser
nothing is uploaded, ever
no sign-up, no account
free — no paid tier, ever
Do it in code

The commands that do it in a terminal

If you have the cluster tooling, you may not need a converter at all. These are the commands that Kubernetes users reach for first.

# One JSON document per resource, separated by newlines.
yq -o=json '.' deployment.yaml

# Every document in a multi-document manifest.
yq -o=json -s '.' ./manifests/

yq - the quickest way, from a file

import json

import yaml

# safe_load_all handles the "---" separators in a multi-document manifest.
with open("deployment.yaml", encoding="utf-8") as f:
    documents = list(yaml.safe_load_all(f))

print(json.dumps(documents, indent=2))

Python - multi-document manifests without extra dependencies

# What the API server actually stores, as JSON.
kubectl get deployment my-app -o json

# As YAML instead.
kubectl get deployment my-app -o yaml

kubectl - straight from the cluster

safe_load_all is the piece people miss: a Kubernetes manifest with several resources separated by --- is a multi-document YAML file, and yaml.safe_load raises an error on it. The converter above handles the same case and returns one JSON object per resource.

The other thing worth knowing is that kubectl get -o json gives you the live object, with every default the API server filled in - creationTimestamp, resourceVersion, uid - not just the fields you wrote. A YAML to JSON conversion gives you exactly what is in your file.

Worked example

A worked example

A minimal Deployment manifest, and the JSON it becomes.

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: web
          image: nginx:1.27
          ports:
            - containerPort: 80

deployment.json

[
  {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "metadata": {
      "name": "web",
      "labels": {
        "app": "web"
      }
    },
    "spec": {
      "replicas": 2,
      "template": {
        "spec": {
          "containers": [
            {
              "name": "web",
              "image": "nginx:1.27",
              "ports": [
                {
                  "containerPort": 80
                }
              ]
            }
          ]
        }
      }
    }
  }
]

Note what did not change: replicas: 2 stays the number 2, containerPort: 80 stays the number 80, and app: web stays a string. That matters in Kubernetes, because the API server rejects a manifest where a number arrived as a quoted string. The output is an array because a manifest file can hold several documents, and the converter returns one element per document - even for a file that holds only one.

Step by step

Convert a manifest in the browser

Useful when the manifest is on your clipboard, or when you cannot reach the cluster from this machine.

  1. Paste the YAML

    Paste the whole file, including the "---" separators if it holds several resources.

  2. Read the JSON

    The output panel shows the JSON for every document, with two-space indentation so it is readable.

  3. Check the types

    Look at the fields you care about - replicas, ports, memory limits. They keep their YAML type.

  4. Copy it into your pipeline

    Paste it into kubectl apply, a Helm template, a CI job, or a policy check.

Why HopConvert

Built for how manifests are actually written

The details that separate a YAML parser that works on manifests from one that does not.

Multi-document files

A manifest with several resources separated by --- is converted completely, not just the first document.

Types stay intact

Numbers remain numbers and quoted strings remain strings, which is what the API server validates against.

Anchors resolved

YAML anchors and aliases are expanded for you, so a shared block is present in every document that uses it.

Manifests stay private

A manifest often contains image pull secrets and internal hostnames. It is parsed in your browser and never sent.

The complete guide

The full YAML to JSON guide

YAML syntax, the types it produces, multi-document files and the quoting rules that catch people out.

Read the YAML to JSON guide

Related tools: YAML to JSON converter · JSON to YAML converter · JSON to SQL · JSON to CSV

FAQ

Frequently asked questions

Multi-document files, types and the commands that already do this in a terminal.

How do I convert a Kubernetes manifest to JSON?
Paste it into the converter above, or use yq -o=json "." deployment.yaml in a terminal, or kubectl get deployment my-app -o json to pull the live object from the cluster.
What about multi-document YAML files?
A file with several resources separated by --- lines is one YAML stream with several documents. The converter parses every document and outputs one JSON object per resource. In Python, use yaml.safe_load_all - safe_load fails on a multi-document file.
Do I need kubectl or a cluster?
No, not for the conversion itself. The converter is client-side and works on a manifest you have on your clipboard. You only need kubectl if you want to compare the result against what the cluster is actually running.
Which YAML values need care?
Anything you quoted on purpose. YAML 1.1 treats unquoted yes, no, on and off as booleans, and unquoted 0755 or 1.2.3 as something other than a string. Kubernetes expects a string for most label and annotation values, so quote them explicitly.
Does it handle anchors and aliases?
Yes. YAML anchors (&name) and aliases (*name) are resolved during parsing, so the JSON contains the expanded value at every place the alias was used.

Convert your manifest now

Free, instant, and private — your manifest never leaves this tab.

Convert the manifest Read the FAQ