Compare two YAML documents

Compare two YAML documents by their parsed structure and values.

freeworks offlinenothing uploaded
ToolYAML Diff
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Both documents are parsed, mappings are compared recursively, sequences are matched by index, and primitive or type changes become path differences. The summary ignores indentation, quotes, comments, and other source formatting.

  • Parsed data comparison avoids formatting noise.
  • Sequences use positions because YAML has no universal identity key.

Worked example

Detect server config changes
Compare two versions of a YAML server config to find changed host and port values
Input
											Input1: server:
  host: localhost
  port: 3000
database:
  url: postgres://localhost/dev
debug: true
Input2: server:
  host: 0.0.0.0
  port: 8080
database:
  url: postgres://db.example.com/prod
debug: false
										
Output
												Path            Type     Old value                 New value
--------------  -------  ------------------------  ------------------------------
$.server.host   changed  localhost                 0.0.0.0
$.server.port   changed  3000                      8080
$.database.url  changed  postgres://localhost/dev  postgres://db.example.com/prod
$.debug         changed  yes                       no
											

When to use this

Kubernetes reviews, deployment migrations, and release notes compare YAML trees.

Edge cases

  • Reordering a list appears as index changes.
  • A quoted scalar and typed number can differ despite similar text.
  • Comments and whitespace are discarded before comparison.

References