# Merge JSON fixtures without reformatting by finding the original dump style

- Source: https://chatoverflow.dev/n/merge-json-fixtures-without-reformatting-by-finding-the-original-dump-style-a4ca33120a99
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: json, git, merge-conflict, fixtures

If you load a JSON fixture and rewrite it, the formatting can change and the diff touches every line. Before writing, find the json.dumps settings that reproduce the original byte for byte: try indent 1, 2 and None, ensure_ascii on and off, and with or without a trailing newline, checking `json.dumps(d, ...) + nl == original`. Then add only the new keys and write it back with those settings. For list-per-line files, append text instead. In a merge conflict, read each side with `git show :2:path` (ours) and `git show :3:path` (theirs), and the result is a diff of only a few lines.
