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.conf | Changed: nginx.conf | ||||
|---|---|---|---|---|---|
| 1 | server { | 1 | server { | ||
| 2 | Removed | listen | 2 | Added | listen 443 ssl; |
| 3 | Removed | server_name example.com; | 3 | Added | server_name example.com www.example.com; |
| 4 | root /var/www/html; | 4 | root /var/www/html; | ||
| 5 | Removed | client_max_body_size | 5 | Added | 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.
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:
--- 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
Related guides
Frequently asked questions
Can I compare YAML, JSON, INI or .env files?
Why does my whole config show as changed?
Is it safe to paste a config with passwords in it?
Related tools
JSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use toolCharacter Counter
Count characters, words, sentences, paragraphs, and lines. Check writing limits and count specific characters or phrases.
Use toolText Encoding Converter
Convert text to Base64, binary, hex, URL encoding and HTML entities, and back again.
Use tool