Mock YAML Generator

Fake YAML config files for testing and demos

Generate valid YAML documents with nested maps, lists, and correctly typed values (strings, numbers, booleans, nulls). Test Kubernetes manifests, CI config parsers, and infrastructure tooling with realistic sample config. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Is the output valid YAML?

Yes. The generator uses two-space indentation, the standard YAML convention, with no tabs (which YAML forbids). Keys map to values via colon-space, lists use hyphen-space, and special string values are quoted so they parse as strings rather than booleans or numbers.

Mock YAML Generator

YAML drives a huge amount of modern tooling: Kubernetes manifests, CI pipelines, and infrastructure configuration all live in YAML files. When you are building or testing a parser, a templating layer, or a config-driven feature, you need valid sample documents that exercise nested maps, lists, and mixed value types. This tool generates that YAML for you.

How it works

The generator builds a tree of values and serializes it with two-space indentation, the standard YAML convention (tabs are forbidden in YAML indentation). Maps emit key: value pairs, lists emit - item entries, and nested structures indent one level deeper per depth.

Type handling follows YAML’s inference rules. Booleans render as true/false, numbers render bare, and null renders as null. Crucially, any string that looks like a boolean, number, or null is wrapped in quotes so the parser keeps it as a string — this prevents the notorious YAML “Norway problem” where a two-letter country code NO becomes false. Three presets shape the output: a generic application config, a Kubernetes-style manifest (apiVersion, kind, metadata, spec), and a CI pipeline (stages, jobs, steps).

Sample output — Kubernetes preset

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-service
  namespace: production
  labels:
    app: my-service
    version: "1.4.2"
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-service
  template:
    metadata:
      labels:
        app: my-service
    spec:
      containers:
        - name: my-service
          image: registry.example.com/my-service:1.4.2
          ports:
            - containerPort: 8080
          env:
            - name: NODE_ENV
              value: production

Note that "1.4.2" is quoted — without quotes YAML would try to parse it as a float (1.4) followed by .2, producing an error.

Sample output — CI pipeline preset

stages:
  - lint
  - test
  - build
  - deploy

jobs:
  lint:
    stage: lint
    script:
      - npm run lint
  test:
    stage: test
    script:
      - npm test
    coverage: "/Coverage: (\\d+)%/"
  build:
    stage: build
    script:
      - npm run build
    artifacts:
      paths:
        - dist/

Common YAML pitfalls this tool helps avoid

Tabs in indentation. YAML forbids tab characters for indentation. The generator uses consistent two-space indentation throughout, so the output never fails on this.

Implicit type coercion. Values like yes, no, on, off, true, false, and bare numbers coerce to their inferred types. This tool wraps any string value that matches a coercible pattern in double quotes, making it explicit.

Inconsistent indentation across nested levels. Deep nesting with hand-written YAML often drifts by one space, breaking the parse. The generator is deterministic — every level is exactly two more spaces than its parent.

Missing document separator. Multi-document YAML files need --- between documents. Single-document output here omits it, which is the correct convention for single-document files.

Tips

  • Validate output with yaml.safe_load (Python) or a YAML linter before using it in production fixtures.
  • The Kubernetes preset is structurally representative but not schema-validated — run it through kubectl dry-run before applying.
  • Increase list sizes to stress-test parser behaviour on longer sequences; off-by-one issues often surface there.
  • If your parser sees a null where you expected a string like “null”, that value needs quoting in the source — the generator shows what quoted output looks like.