Duplicate %YAML Directive – Remove Repeated YAML Version Directives
Local only
A YAML document cannot repeat the %YAML version directive in the same directive section. Keep one version declaration before the document start marker.
36 chars · 4 lines
Waiting for input
Loading YAML parser…
YAML directive duplication troubleshooting
How to fix a duplicate %YAML directive
The sample declares %YAML 1.2 twice before one document. A directive section may not repeat the YAML version directive, so the parser rejects the stream before it reaches the service mapping. This tool is free to use. No account or payment is required.
Last updated
What you can do here
YAML 1.2 parser validation
Duplicate mapping key detection
Preloaded broken YAML example
Readable parser feedback
.yaml and .yml file import
Browser-local processing
Steps
Inspect the directive lines before the first --- document marker.
Remove repeated %YAML version directives and keep the intended one.
Validate again and check any generated or concatenated source that created the duplicate header.
Duplicate directives often come from concatenation
Templates or build steps can accidentally combine two YAML headers into one directive section. Fix the generator as well as the current output if the duplicate directive keeps returning.
A directive applies to the document that follows
Keep directive metadata at the stream boundary and separate it from data with ---. Ordinary application configuration usually does not need repeated version declarations inside the content itself.
Repeated YAML version directive example
Keep a single %YAML 1.2 line before the explicit document start.
Invalid YAML
%YAML 1.2
%YAML 1.2
---
service: api
Corrected YAML
%YAML 1.2
---
service: api
Common questions
Frequently asked questions
Can I put %YAML 1.2 twice before one document?
No. Repeating the YAML version directive in the same directive section is invalid.
Does every YAML document need a %YAML directive?
No. Most configuration documents omit it unless an explicit version directive is useful for the workflow.
What should follow a YAML directive section?
An explicit --- document start marker separates directives from the following YAML document content.