Docs / Editing tools
Diff and compare
Last updated:
Diff and Compare shows the differences between the open document and another document you paste. It highlights changes down to the word. Diff and Compare is a Pro feature in Prettify. Free users get one try per day.
Compare two documents
The open document is the first side. You supply the second side by pasting it.
- Load a document in the editor.
- Click Diff / Compare in the toolbar, under the Transform group.
- Paste the data to compare against the current document.
- Press
Cmd+Enter(Mac) /Ctrl+Enter(Windows, Linux), or click Compare.
Prettify parses the pasted text with the current format. If the text does not parse, Prettify shows the error and does not compare. The result labels the two sides Current and Pasted.
Text diff and semantic diff
Prettify offers two diff modes.
- Text: compares the two documents line by line. It is available for every format.
- Semantic: compares the parsed data by structure. It is available for JSON and YAML.
Switch modes with the Text and Semantic buttons at the top of the diff.
Text diff
Text diff has two layouts.
- Split shows the two documents side by side.
- Unified shows one combined column.
Split is the default on wide screens; Unified is the default on a phone. Added and removed lines are colored, and changed words inside a line are highlighted. The header shows counts of added and removed lines.
Semantic diff
Semantic diff lists each change by its path, such as users[0].email. Object keys join with a dot and array positions are in brackets. It marks each entry as added, removed, or changed, and shows the old value next to the new value. Objects are compared without regard to key order, so a reordered object shows no change.
You can export a semantic diff as a JSON Patch (RFC 6902). Use the copy button, or download it as diff.patch.json. The patch writes each path as a JSON Pointer, such as /users/0/email.
Move between changes
Step through the changes with the navigation controls, or the keyboard.
- Press
Alt+Down, orn, for the next change. - Press
Alt+Up, orp, for the previous change.
The header shows the active change, for example 2 of 7. Prettify shows No differences found when the two sides match.
Related
- Split view to keep two documents open at once
- History and versions
- Prettify Pro
Try it online
Tool pages for this topic. Each one runs in your browser.