DiffKit / YAML compare

YAML compare

Paste two YAML files, such as compose files, Kubernetes manifests or CI workflows. They’re parsed, rewritten in one consistent style and compared key by key.

16 lines
17 lines
Loading the comparison…

Reading the result

The side-by-side view shows both files after normalisation, with keys sorted, one consistent indentation and block-style lists. Under it, Changed keys names each difference by path. In the example, $.services.web.image moved from nginx 1.25 to 1.27, a second port was added at $.services.web.ports[1], and the database gained a healthcheck. The web and db services swapped places, but that isn’t reported as a change.

Common YAML gotchas this catches

  • Type changes: WORKERS: 2 is a number, WORKERS: "2" is a string. Tools such as Kubernetes are strict about this.
  • Indentation slips: a key indented one level too deep moves under a different parent, and its path shows exactly where it ended up.
  • Invalid syntax: tabs used for indentation or an unclosed quote are reported with the parser’s message.

For JSON files, the JSON compare works the same way.

Questions people ask

Why does YAML need a special compare tool?

The same YAML data can be written in block style or flow style ([a, b] vs. a dashed list), with keys in any order and with different quoting. A text diff flags all of that. DiffKit parses both files and re-writes them in one consistent style first, so only real value changes remain.

Are comments compared?

No. Comments are not part of the YAML data model, so they are dropped during normalisation. Use the plain diff checker if you need to review comment changes.

Which YAML version is supported?

YAML 1.2, via the widely used “yaml” JavaScript library. Anchors and aliases are expanded, and multi-document files use the first document.

Can I compare Kubernetes manifests, GitHub Actions workflows or OpenAPI specs?

Yes. Any single YAML document works, including Helm values, docker-compose files, CI workflows and OpenAPI definitions.

Other comparisons