Skip to content
86% off$349 $48.86code BF2026

Guides

Validate YAML Tab Indentation Errors in Kubernetes Manifests

Tabs aren't valid YAML indentation. Find them with grep, yamllint or Bytepliers, then check the schema with kubeconform, a server dry run or helm template.

GuideUpdated 6 min read

On this page

You ran kubectl apply -f, the file looks right, and either it errors or the resource is created but does nothing. Those are two different problems with two different tools, and this guide covers both.

text
error: error parsing deploy.yaml: error converting YAML to JSON: yaml: line 9: found character that cannot start any token

The exact wording depends on your kubectl version, but "found character that cannot start any token" on a line that looks fine often means a tab.

Why a manifest that looks fine fails

Tab characters. Indentation carries meaning in YAML, and the specification does not allow tabs as indentation. Editors display a tab as a few spaces, so the file looks aligned while the parser sees an illegal character. This is the most common cause of a parse error.

Wrong nesting. The file is valid YAML but says something different from what you meant. For example, a field you meant to put next to backend ends up one level too deep, under service. A YAML syntax checker is happy with that. Whether kubectl rejects it, warns, or silently drops the stray field depends on your kubectl version and validation settings. People on the Kubernetes subreddit have reported an Ingress that was created but did not work for days because sections were one level too deep.

Other syntax slips. An unquoted value containing : , list dashes that do not line up, or a key indented under a line that already has a value. These show up as "mapping values are not allowed here" and similar messages.

Template output (Helm). In a chart, indentation problems usually appear after rendering, for example a wrong nindent.

SymptomLikely causeFix
"found character that cannot start any token"Tab in indentationReplace tabs with spaces
"mapping values are not allowed here"Unquoted : in a value, or bad indentQuote the value, fix the indent
Applies, but the resource does nothingField at the wrong level or misspelledkubeconform -strict, kubectl explain
Error after helm install onlyBad indentation in rendered outputhelm template, then lint the output

Step-by-step: find and fix the problem

1. Find tabs with grep (built in)

This is read-only and needs nothing installed. It prints every line containing a tab, with line numbers:

bash
grep -n $'\t' your-manifest.yaml

No output means no tabs. A tab inside a quoted string can be legal, so check that each hit is in the indentation.

2. Convert tabs to spaces

This writes a new file and leaves the original untouched:

bash
expand -t 2 your-manifest.yaml > your-manifest.fixed.yaml

expand replaces every tab with spaces up to the next tab stop, including tabs inside values. Review the result before you replace the original. The better long-term fix is your editor's setting to insert spaces when you press Tab.

3. Lint syntax and indentation with yamllint

yamllint is a command-line linter for YAML syntax and style. With Homebrew:

bash
brew install yamllint
yamllint your-manifest.yaml

Each finding comes with a line and column. By default it also applies style rules such as line length, which can be noisy on Kubernetes files. Use its built-in relaxed preset to tone that down:

bash
yamllint -d relaxed your-manifest.yaml

yamllint knows YAML, not Kubernetes. It will pass a manifest that is valid YAML but has the right fields in the wrong places.

4. Check one document in Bytepliers

If you would rather paste a snippet into a window than use Terminal, Bytepliers has a YAML ↔ JSON tool that works offline.

  1. Open Bytepliers and choose YAML ↔ JSON in the Convert group of the sidebar, or press ⌘K and type "yaml".
  2. Paste your manifest, or drop the file on the editor.
  3. Leave the mode on YAML → JSON.
  4. If the YAML is invalid, including tab indentation, the error starts with Line N:.
  5. If it is valid, read the JSON output. Each nested object appears at its real depth, so a field one level too deep is easy to spot.

For a longer document, copy the JSON into JSON Formatter and switch its output to Tree to click through the structure.

5. Check the Kubernetes schema with kubeconform

kubeconform validates manifests against Kubernetes resource schemas. This is the step that catches a misplaced field.

bash
brew install kubeconform
kubeconform -strict -summary your-manifest.yaml

-strict rejects fields the schema does not define, which is what a wrongly nested key often looks like. -summary prints a count of valid and invalid resources. For custom resources (CRDs) there may be no schema available; -ignore-missing-schemas skips those instead of failing.

6. Ask the cluster without changing anything

If you can reach a cluster, the API server is the final authority on what your manifest means:

bash
kubectl apply --dry-run=server -f your-manifest.yaml

This sends the manifest to the API server for validation and does not persist it. If the object already exists, compare what you are applying with what is stored:

bash
kubectl diff -f your-manifest.yaml
kubectl get ingress my-ingress -o yaml

To check where a field belongs, ask kubectl directly:

bash
kubectl explain ingress.spec.rules

7. Check Helm charts with helm template

Render the chart and validate the output rather than the template files:

bash
helm template my-release ./my-chart > rendered.yaml
yamllint -d relaxed rendered.yaml
kubeconform -strict -summary rendered.yaml

If helm template fails with a YAML parse error, the line number refers to the rendered output, not your template file. Add --debug to print the rendered text so you can find that line. helm lint ./my-chart is also worth running. Use the same values file you use for the install.

Which check to use

You want to catchUseNeeds
Tab characters onlygrep -n $'\t' file.yamlNothing (built in)
Syntax, indentation, duplicate keys, styleyamllintHomebrew install
Syntax plus a view of the parsed structure, one document at a timeBytepliers YAML ↔ JSONBytepliers
Wrong fields, wrong nesting, bad typeskubeconform -strictHomebrew install
What your cluster will acceptkubectl apply --dry-run=serverCluster access
Helm template mistakeshelm template, then the checks aboveHelm

Checklist before you apply again

  • No tab characters in the indentation (grep -n $'\t' prints nothing).
  • yamllint -d relaxed reports no errors.
  • kubeconform -strict passes, or CRDs are explicitly skipped.
  • kubectl apply --dry-run=server succeeds.
  • For Helm, you validated the rendered output with the same values file as the install.

If nothing works

Start with the line above the reported error: a tab or bad indent on the previous line often surfaces on the next one. For "mapping values are not allowed here", look for an unquoted value containing : . For list problems, make sure every - in one list shares the same indentation and that keys inside an item align with the first key after the dash.

If it still fails, ask in the support channel for your cluster, chart or distribution, and include the details below.

text
Hi, kubectl apply fails on my manifest and I can't find the cause.

Exact error: <paste the full error text>
kubectl version: <output of kubectl version>
Tried: grep for tabs (none/found on lines ...), yamllint, kubeconform -strict, kubectl apply --dry-run=server
Manifest (secrets removed): <attach the smallest file that still fails>

Common questions

Can I just replace tabs with spaces?

Yes, but pick one step (2 spaces is common) and check that the nesting still matches what you intended. Leading tabs convert cleanly; tabs mixed with spaces need a closer look.

Does kubectl apply validate the manifest?

It parses the YAML and the API server checks the object. How strictly unknown fields are handled depends on your kubectl version and validation settings, so run kubeconform -strict or a server dry run before relying on it.

Why does the error point at a line that looks fine?

The parser often notices the problem one line late. Check the named line and the one above it, and run the grep check to rule out tabs.

Can Bytepliers validate Kubernetes schemas?

No. It reports YAML syntax errors and shows the parsed structure. Bytepliers is part of MacSuite, and you can try it free for 7 days; the tool reference lists every tool.

Every app.
One purchase.