How to merge YAML files in layers
Load at least two YAML sources with Drop YAML files here and browse files, or paste text into Paste a YAML source and click Add source. The page parses, merges, and prepares downloads in the browser.
- Use
browse files, or fillPaste a YAML source, optionally addSource name, and clickAdd source. - Check the source order. It affects
First source wins,Last source wins, andConcatenate (append in source order). - Choose a
Pairing modefor single documents or matching multi-document streams. - Set
Merge mode,Precedence for scalar & type conflicts,Null policy, andGlobal sequence handling. - Set the policies for
Anchors (&) & aliases (*),Merge keys (<<),Comments, andDocument boundaries (multi-document sources). - Review the preview and logs, then click
Export merged YAMLorExport merge report (JSON).
Merge YAML documents with the right pairing mode
Pair by document position across streams (source counts must match) combines document 1 from every source, then document 2. Counts must match, with one output document for each position.
Treat each source as exactly one document requires one document per source. A multi-document source blocks this mode.
Choose YAML merge rules for nested keys and sequences
Deep (recursive merge at every level) combines child keys inside nested mappings. Shallow (top-level keys only) replaces a nested mapping as one value. Last source wins and First source wins choose conflicting scalars, types, and replacement sequences.
Sequence choices are Replace (precedence picks one sequence), Concatenate (append in source order), Union (dedupe by full value, order preserved), and Merge by key (sequences of mappings). Add a dot-notated path such as items with Add path override for a local rule. An empty key field falls back to replacement; items without it remain raw.
Two sources with separate fields produce this output:
base.yaml:
port: 80
override.yaml:
host: app
merged:
port: 80
host: app
What YAML Merge Tool does with nulls, comments, and aliases
Null is a value (can win/lose conflicts normally) includes explicit null values in conflict resolution. Null means absent (ignored unless every source is null) ignores null when another value exists.
Expand to value before merge, log every occurrence resolves anchors and aliases before merging. The blocking choice stops the merge when one appears. The merge-key policy treats << as pre-resolved and logs it, or blocks that source. With Proceed, log that comments are discarded (never preserved on output), comments are dropped during parsing and serialization.
Review conflicts and blocked YAML merges
The result workspace shows Merged YAML preview, Every conflict & resolution, and Unsupported / logged constructs. Conflict entries show paths, candidate values, rules, sources, and output values. Logged constructs include source and line when available.
Malformed YAML, unequal document counts in position mode, a multi-document source in single mode, or a blocking policy prevents the merge. The parser can reject YAML syntax it does not handle. The tool does not check an external schema.
Layered YAML examples
Load base.yaml first and override.yaml second when the second source should take precedence. Set Last source wins, then inspect conflicts before exporting.
For lists of mapping objects, choose Merge by key (sequences of mappings) and enter a field in Global sequence merge key field. Entries with the same field value are merged; entries without it remain raw.
Merge output versus a YAML diff
This page produces merged YAML, a conflict log, and a construct log. It does not compare versions or validate an external schema. The Config File Merge Tools category lists other merge pages.
Frequently asked questions
How do I merge YAML files with an override file?
Load the base file first and the override second. Choose Last source wins, then review Every conflict & resolution before exporting.
Can I merge multi-document YAML streams?
Matching streams can use Pair by document position across streams (source counts must match). Use Treat each source as exactly one document only when each source has one document.
Are comments preserved when YAML files are merged?
Comments are discarded when Proceed, log that comments are discarded (never preserved on output) is selected. Choose Block the merge if any source contains comments to stop on comments.
How do I merge YAML lists by an id field?
Choose Merge by key (sequences of mappings) and enter the field in Global sequence merge key field. Items without that field remain raw.
Does the YAML Merge Tool upload my files?
The page makes no upload request. It reads, parses, and merges selected files in the browser, then creates exports locally. The source files are not changed.