Combine two YAML documents

Combine two YAML documents with recursive mappings and selectable sequence behavior.

freeworks offlinenothing uploaded
ToolYAML Merge
Input
Output

How it works

Both values are parsed, mappings merge recursively, scalar conflicts use the later document, and sequences replace, concatenate, or concatenate uniquely according to the option. The result is serialized as YAML.

  • Sequence replacement is the least-assumptive default.
  • Explicit list modes support overlay files.

Worked example

Deep merge config overrides
Merge base server config with environment-specific overrides. Nested keys are merged recursively
Input
											Input1: server:
  host: localhost
  port: 3000
database:
  host: localhost
  port: 5432
Input2: server:
  port: 8080
  ssl: true
logging:
  level: debug
										
Output
												server:
  host: localhost
  port: 8080
  ssl: true
database:
  host: localhost
  port: 5432
logging:
  level: debug

											

When to use this

Helm values, Ansible variables, and deployment overlays merge YAML.

Edge cases

  • A scalar replacing a mapping discards the earlier branch.
  • The append mode keeps repeated sequence items unless unique mode is selected.
  • Anchors can resolve into ordinary values during parsing.

References