YAMLTools & Guides

YAML Validator Indentation Fix – Stabilize Kubernetes Rollouts

Paste your YAML and get indentation errors with exact line numbers

No signup • Runs in browser • Free

Fix YAML Indentation →

A single misaligned space in a ConfigMap invalidates the manifest right before deployment. The error mapping values are not allowed here tells you something is wrong with the structure but not which of the 80 lines is the culprit. Indentation-aware validation pinpoints the row so you can repair it without scanning the entire file manually.

YAML indentation errors are particularly frustrating because they are invisible. A space at column 3 versus column 4 looks identical in most editors unless you enable whitespace visualization. A YAML validator treats indentation as part of the parse and reports the exact line where the structure breaks — turning a five-minute guessing exercise into a ten-second fix.

# Indentation error — containers block is at the wrong depth
spec:
  replicas: 2
  template:
    spec:
        containers:       # ← 8 spaces — should be 6 (one level under spec)
        - name: web
          image: nginx

# Fixed — consistent 2-space indentation throughout
spec:
  replicas: 2
  template:
    spec:
      containers:
      - name: web
        image: nginx

Quick summary

  • YAML indentation is part of the structure — one wrong space changes the nesting level.
  • A validator pinpoints the exact line number rather than leaving you to scan manually.
  • Reformatting normalizes to 2-space indentation without changing your data.
  • DevToolBox tools run entirely in your browser — no signup.

What It Is

A YAML validator checks the structure and syntax of your YAML file, including indentation consistency. Unlike a syntax highlighter that shows color-coded keys and values, a validator parses the file the same way a YAML parser would and reports every structural violation.

For indentation errors specifically, the validator identifies where the actual indentation depth diverges from what the surrounding structure implies it should be. This is the same check that kubectl apply and helm install perform internally — running it locally first gives you the error message with context, not a deployment failure with a stack trace.

Why Developers Use This

  • Fixing ConfigMap and Secret manifests. These resources use block scalars and multi-line values that are especially sensitive to indentation. A validator confirms the nesting is correct before the resource is applied.
  • Templating Helm charts by hand. Engineers who edit values.yaml or chart templates directly sometimes introduce indentation drift when adding new keys. Validating the rendered output of helm template before installing confirms the chart produces valid YAML.
  • Reviewing PRs that touch infrastructure YAML. A linter check in CI catches indentation regressions before they reach the merge queue. See our guide on YAML validation online for a deeper explanation of why indentation matters in YAML.
  • Normalizing files from different editors. When YAML files come from multiple contributors using different editors, indentation depth can vary. The formatter normalizes everything to 2-space indentation.

Common YAML Indentation Errors

  • Indentation drift. A block indented by 4 spaces when the surrounding structure uses 2 silently misaligns the nesting. The parser may interpret the block as a child of the wrong parent key.
  • Tab characters. YAML explicitly forbids tabs for indentation. A single tab character produces found character '\t' that cannot start any token — configure your editor to convert tabs to spaces automatically.
  • Colon without space. env: VAR is a key-value pair. env VAR is treated as a plain string. Missing the colon-space separator is easy to do under time pressure and produces no visual warning in most editors.

How to Use the YAML Linter

Using the DevToolBox YAML Linter to fix an indentation error takes under a minute.

  1. Open the linter in your browser. No account, no install.
  2. Paste your YAML manifest or config file into the input box.
  3. Click Lint & Format. If errors are found, each one includes a line number badge.
  4. Fix the indentation issue in your original file at the reported line, paste again, and re-lint.
  5. Once no errors are reported, copy the formatted output — it uses consistent 2-space indentation throughout.

DevToolBox tools run entirely in your browser — nothing you paste is transmitted to any server.

Frequently Asked Questions

Does the linter understand Kubernetes-specific schemas?

The linter validates YAML syntax including indentation. For Kubernetes schema validation — checking whether a field name is valid for a specific resource version — you need a tool like kubeval or kubeconform. Syntax is always the first hurdle; schema validation builds on top of it.

How do I keep indentation consistent across my team?

Add an .editorconfig file to your repo with indent_style = space and indent_size = 2 for YAML files. This enforces consistent settings across VS Code, IntelliJ, and other editors that respect .editorconfig.

Can YAML linting run in a pre-commit hook?

Yes. Add yamllint or prettier --check to your .pre-commit-config.yaml. The online linter is ideal for quick checks during authoring; the pre-commit hook enforces consistency at commit time for the whole team.

Conclusion

A misaligned space in a Kubernetes manifest causes a deployment failure with an error message that gives you almost nothing to work with. Indentation-aware validation pinpoints the row so you can repair it in seconds rather than minutes. The linter runs the same check the YAML parser would — before the cluster is involved.

If you need a fast YAML validator that pinpoints indentation errors and reformats to consistent 2-space depth, DevToolBox does exactly that. DevToolBox tools run entirely in your browser — no signup, no install, nothing sent to a server.

Fix YAML indentation errors in seconds

Paste your manifest, get errors by line number, and download a cleanly formatted copy. Free, no signup, browser-only.

Fix YAML Indentation →

Related Articles

Helpful tools for YAML

Also read: