Skip to content

Edit a config file safely

This guide changes one setting in a JSON config file without touching anything else in it: you find the setting, change its value, compare your version with the file on disk, and then save or undo. Your edits stay in a copy of the file until you save, so the file other programs read does not change before then.

The file must be a JSON file in UTF-8, opened from disk, and up to 2 GiB. NDJSON files, compressed files, and pasted or fetched documents open read-only; see What you can edit.

The steps use this file, saved as config.json:

config.json
{
"server": {
"host": "0.0.0.0",
"port": 8080
},
"logging": {
"level": "info"
},
"features": ["search", "export"]
}

Close the file in other programs before you save; see Saving replaces the original.

Open config.json with Ctrl+O. Press Ctrl+P, type port, and press Enter on $.server.port. The tree expands server and selects port. See Go to a path.

  1. With port selected, press F2. The value becomes an editable box.

  2. Type 8081 and press Enter.

The tree shows "port": 8081, and a dot on the tab means the file has unsaved edits. The file on disk still says 8080.

To change several fields at once, use the subtree editor. To rename a key or add and remove members, see Rename, insert, and delete.

The Compare view shows every difference between your version and the file on disk.

  1. Click the top row of the tree, {3}, so that the comparison covers the whole document. The click also collapses the tree; that does not matter here.

  2. Select Compare in the view switcher.

  3. Select Compare with file… and choose config.json, the file you are editing.

Your version is on the left and the file on disk on the right. The Patches list shows one difference: replace at /server/port. A difference you did not expect means an edit went wrong; undo it before you save. See Compare view.

  • Save: press Ctrl+S. JSON Digger replaces config.json with your version in one step and shows “Saved.” The dot on the tab disappears.
  • Undo: press Ctrl+Z to undo the last edit, before you save.
  • Drop every edit: choose File → Discard Edits and confirm with Discard.

If you close the tab first, JSON Digger asks “Save changes to config.json?” with Save, Discard and Close, and Cancel. If it closes unexpectedly, it offers to recover your edits the next time it starts. See Save, undo, and recover edits.