Kubernetes Multi-Document YAML Splitter

Paste a helm template render, a kustomize build, or any bundle with separators in it. You get one file per object, named in apply order, with the original text preserved and anything defined twice called out.

Paste below, or drop a file anywhere on this panel

Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.

The answer appears here

Paste on the left and press Split. Nothing leaves this tab.

Examples

Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.

Two objects with the same name

A duplicate that apply will silently resolve to whichever came last

apiVersion: v1
kind: Service
metadata:
  name: api
---
apiVersion: v1
kind: Service
metadata:
  name: api

A multi-document file

One file split into the files kubectl apply -f would treat separately

apiVersion: v1
kind: Service
metadata:
  name: api
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api

Common mistakes

These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

  1. Leaving two objects with the same kind and name

    kubectl apply processes documents in order and the last one wins, silently.

    Instead:Split and check for duplicates before applying.

  2. Using --- inside a literal block

    A --- inside a block scalar is content, not a separator, and a naive splitter breaks the document.

    Instead:Split with a YAML parser, not a string split.

  3. Assuming apply order matches file order

    kubectl does not sort by dependency. A Deployment referencing a ConfigMap defined later in the same file still applies first.

    Instead:Apply in dependency order, or rely on the controller retrying.

What it catches

Splitting is the easy half. The rest is what a generated bundle hides from you, and all of it is readable from the file itself.

The text comes back exactly as it went in

Every other splitter parses the YAML and dumps it out again, which deletes every comment, expands every anchor and rewrites the quoting. Here each document is the literal bytes between its separators. The parser still runs, but only to read each object's identity and to check that its idea of how many documents there are matches the split.

The same object defined twice

Same kind, same namespace, same name, twice in one bundle. kubectl applies them in order and the last one wins, with no warning and nothing in the diff. Editing the first copy then appears to do nothing at all, which is a long afternoon. Reported as critical, with the line numbers and which one currently takes effect.

Apply order, which kubectl does not fix for you

kubectl apply -f on a single file processes documents top to bottom and does not sort them. A Deployment written above the Namespace it lives in works on every cluster where someone already created that namespace, and fails on the first clean install. Files come out numbered in dependency order.

Lists, CRDs and documents that render to nothing

kubectl get -o yaml wraps everything in a List, which is one document containing many objects; it gets unwrapped. A CRD in the same bundle as a resource of that kind cannot apply in one pass and says so. Helm conditionals that rendered empty leave documents with no kind, and those are flagged rather than written to a file.

Why a bundle is not just a file with --- in it

A multi-document manifest is the normal output of helm template, kustomize build and kubectl get. Splitting one is easy; the reason to do it carefully is that the separator carries ordering and identity information that nothing else in the file records.

The separator is a document boundary, not a delimiter

Three hyphens at the start of a line begins a new document. It has to be at column zero, and no scalar in block context can have a continuation line at column zero, so nothing inside a value can be mistaken for one. That is why a certificate chain in a ConfigMap splits correctly here and breaks a sed one-liner.

data:
  chain: |
    -----BEGIN CERTIFICATE-----     <- indented, so it is
    AAAA                               content, not a
    -----END CERTIFICATE-----          separator
---                                 <- column zero, so it is

Order matters, and only inside a single file

Within one file, documents are applied in the order written. Across a directory, kubectl reads the files alphabetically. That is the entire ordering guarantee you get, and it is why generated bundles are numbered. There is no dependency resolution anywhere in kubectl apply.

01-namespace-prod.yaml        created first
02-serviceaccount-api.yaml
03-configmap-api.yaml
10-deployment-api.yaml        by which point everything
                              it references exists

without the leading zero, 10- sorts before 2-

A duplicate is not an error

Two documents defining the same object is a valid file. kubectl sends both, in order, and the object ends up as whatever the second one said. There is no warning, and kubectl diff shows the net result, so the redundant copy is invisible in review as well as at apply time.

kubectl apply -f bundle.yaml

configmap/app configured
configmap/app configured    <- the same object, twice

the second wins, and nothing says so

CRDs need two passes, always

A CustomResourceDefinition and a custom resource of that kind cannot be applied together. The API server has to register the new endpoint before it can validate a resource against it, and within one apply it has not done that yet. The error names the kind, so it reads like a typo rather than a timing problem.

kubectl apply -f bundle.yaml
error: unable to recognize "bundle.yaml": no matches
for kind "Certificate" in version "cert-manager.io/v1"

kubectl apply -f 01-crd.yaml
kubectl wait --for condition=established --timeout=60s \
  crd/certificates.cert-manager.io
kubectl apply -f .

More kubernetes tools

Kubernetes YAML Generator Answer a few questions, get a manifest Kubernetes YAML Validator Is this YAML valid, and where is it wrong? Kubernetes Rollout & Probe Timing Restart loops, capacity dips and stuck drains Kubernetes Service Checker Will this Service have any endpoints? Kubernetes Network Policy Viewer What can reach what, and what just broke Kubernetes Manifest Diff What actually changed Kubernetes Resource Calculator What these manifests actually reserve Kubernetes RBAC Viewer Who can actually do what Kubernetes Deployment Generator See the capacity dip before you deploy Kubernetes Service Generator port, targetPort, and which one you meant Kubernetes StatefulSet Generator Stable names, and volumes that outlive you Kubernetes QoS Class Calculator And where you sit in the eviction order Kubernetes Node Capacity Planner Allocatable is not capacity Kubernetes Max Pods per Node Calculator The ENI limit, not the 110 default Kubernetes Label Selector Tester Which key failed, not just that one did Kubernetes Taint & Toleration Tester Tolerations permit, they do not attract Kubernetes Resource Name Validator RFC 1123 subdomain, label, or 1035 Kubernetes Label & Annotation Validator Why your image tag is not a legal label Kubernetes CrashLoopBackOff Guide The status is a timer, not a cause Kubernetes TLS Certificate Decoder When it expires, and what it covers Kubernetes ServiceAccount Token Decoder Bound or legacy, and when it dies Kubernetes imagePullSecret Generator The registry URL nobody gets right Kubernetes cert-manager Certificates Issuer scope, and the rate limit that costs a week Kubernetes Flux HelmRelease Generator With the source it cannot work without Kubernetes Helm Chart Generator Chart.yaml, values, and working templates Kubernetes Argo CD Application Generator The defaults that are off, turned on Kubernetes Ingress Generator pathType, and the TLS secret that fails quietly Kubernetes HPA Generator Why it says unknown and never scales Kubernetes SecurityContext Generator Pod level, container level, and which wins Kubernetes Probe Generator How long it gets to start before liveness kills it Kubernetes PVC Generator Access modes your storage can actually do Kubernetes ResourceQuota Generator And the LimitRange that stops it breaking deploys Kubernetes CronJob Generator The fields that decide whether it runs Kubernetes NetworkPolicy Generator With the DNS rule already in it Kubernetes RBAC Generator And what it actually grants Kubernetes PodDisruptionBudget Generator Can this budget ever be satisfied? Kubernetes API Deprecation Checker What breaks on the next upgrade Kubernetes Kubeconfig Viewer Read it without handing it to anyone Kubernetes Quantity Parser What 512Mi, 100m and 1e3 actually mean Kubernetes .env to ConfigMap & Secret Split the credentials out on the way Kubernetes Secret Decoder See what is actually in there Kubernetes Ingress to Gateway API Which annotations silently stop working Kubernetes Manifest Visualizer What points at what, and what points at nothing Kubernetes Patch Tester Which --type, and what it deletes Kubernetes kubectl JSONPath Tester kubectl's dialect, not generic JSONPath Kubernetes Node Affinity Tester Required excludes, preferred only scores Kubernetes Helm Values Diff A missing key is a third value Kubernetes Pod and Service CIDR Fixed at cluster creation Kubernetes Secret Encoder base64 is not encryption Kubernetes API Version Checker Will this apply on that cluster Kubernetes Go Template Tester Go truthiness is not JavaScript's Kubernetes Cluster Cost Estimator At your rates, not a price table Kubernetes Kustomize Build Transformers run in kustomize's order Kubernetes Helm Chart Validator version is SemVer, appVersion is not

Elsewhere on the site