How to compare two config files and find the setting that changed

By TechCompare · Updated · How we check

Paste both config files and read only the changed lines. Word marks inside each line point at the exact value that differs, like a port number or a size limit.

The example

2 changes: 3 lines removed, 3 added

Original: nginx.confChanged: nginx.conf
1server {1server {
2Removed listen 80;2Added listen 443 ssl;
3Removed server_name example.com;3Added server_name example.com www.example.com;
4 root /var/www/html;4 root /var/www/html;
5Removed client_max_body_size 1m;5Added client_max_body_size 10m;
6 6
7 location / {7 location / {
8 try_files $uri $uri/ =404;8 try_files $uri $uri/ =404;
9 }9 }
10}10}

When a service works on one server and fails on another, the answer is often one line in a config file. Comparing the two files by eye is slow and easy to get wrong. A text diff lines them up, skips the lines that match and marks the values that differ, so a changed port or a missing option stands out in seconds.

Changes in the example
2
3 lines removed, 3 added
Lines
10 and 10
Original and changed text
Category
Files and data
Text diff guides

How this is calculated

The example compares two versions of an nginx server block. The tool finds 2 separate changes, with 3 lines removed and 3 added. The listen line moved to port 443 with TLS, the server picked up a second name, and the upload limit went up. Inside each changed line only the edited words are marked, so you don't have to read server_name example.com www.example.com letter by letter to see what's new.

Here's the same change as a unified diff, the format the Copy button gives:

Unified diff
--- a/nginx.conf
+++ b/nginx.conf
@@ -1,8 +1,8 @@
 server {
-    listen 80;
-    server_name example.com;
+    listen 443 ssl;
+    server_name example.com www.example.com;
     root /var/www/html;
-    client_max_body_size 1m;
+    client_max_body_size 10m;
 
     location / {
         try_files $uri $uri/ =404;

A few habits make config diffs easier to read:

  • Compare the files as they are on disk, not after an editor reformats them. If one copy was reindented, turn on Ignore whitespace so only real edits show.
  • Line endings don't count. A file saved on Windows with CRLF endings matches the same file with LF endings, and the tool tells you the endings differ.
  • Order matters in a text diff. If a tool wrote the settings in another order, the moved lines show as removed in one place and added in another. Sort both files first, or for JSON use a structural compare that ignores key order.
  • The texts stay private. The comparison runs in your browser and the text stays out of the URL. Still, take passwords and API keys out of a copied patch before you share it.

Verdict

Diff the config that works against the one that doesn't before you change anything else. Most problems show up as one or two changed lines. If the diff is long, check whether a formatter, a sorted export or a different editor caused it. Those changes hide the real edit, and Ignore whitespace or sorting both files will clear most of them.

More Text Diff scenarios

Frequently asked questions

Can I compare YAML, JSON, INI or .env files?
Yes. The tool compares any plain text line by line, so the file type doesn't matter. For JSON, a structural compare can fit better, because it ignores key order and formatting. The JSON Formatter's compare mode does that.
Why does my whole config show as changed?
Usually the indentation or the order of the settings changed. Line endings never count here, so it isn't those. Turn on Ignore whitespace for reindented files. For settings written in another order, sort both files before comparing, or use a tool that understands the format.
Is it safe to paste a config with passwords in it?
The texts stay in your browser. They aren't uploaded and they don't go into the page URL. Treat a copied patch like the files themselves, though, and take secrets out before you post it anywhere.