Split a multi-document YAML file

Split a multi-document YAML stream into separately serialized documents.

freeworks offlinenothing uploaded
ToolYAML Splitter
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The input is parsed at standard --- document markers, each YAML value is serialized independently, and the count reports how many stream items were found. Empty marker sections follow parser null-document behavior.

  • --- is the standard stream separator.
  • Independent output makes manifest files easier to copy.

Worked example

Split Kubernetes Service + Deployment
Split a multi-document K8s manifest file into individual YAML documents
Input
											---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  ports:
    - port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 2
										
Output
												Documents: apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  ports:
    - port: 80
, apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 2

Count: 2
											

When to use this

kubectl manifests, deployment bundles, and sequential YAML streams split documents.

Edge cases

  • A --- inside a quoted scalar is data rather than a marker.
  • ... closes the current stream item.
  • An empty section can become a null document.

References