Format, minify, clean and sort
Make documents readable, compact or valid again, and sort arrays, keys or lines.
Format and minify
| Action | Shortcut | What it does |
|---|---|---|
| Format | ⇧⌥F | Indents JSON, NDJSON, YAML, XML and SQL so they are easy to read |
| Minify | ⇧⌥M | Removes whitespace and puts JSON on a single line; SQL is compacted |
Both are in the editor toolbar and the command palette. Formatting runs off the main thread, so the window stays responsive on big documents; click Cancel to stop a long run — the document stays unchanged.
Clean: repair broken JSON
Real-world JSON often arrives broken: copied from a log with a BOM in front, written by hand with comments and trailing commas, or double-escaped by another tool. When Quap finds such problems the toolbar button changes to Clean and format (or Clean and minify). One click:
- removes a byte-order mark (BOM) and invalid control characters,
- strips
//and/* … */comments, - removes trailing commas,
- fixes over-escaped quotes,
and then formats the result.
// exported from staging
{
"id": 7,
"tags": ["a", "b",],
}{
"id": 7,
"tags": ["a", "b"]
}Sort
Click Sort in the editor toolbar. The dialog has three modes:
Sort the items of an array by one of their properties.
- Pick the Array path — the list shows every array in the document; type to filter.
- Pick the Property. For objects inside objects, click
object →to drill in; pick item value to sort plain values. - Choose ASC or DESC and click Sort.
Key sorting is also in the tree's context menu: Sort keys A→Z, Sort keys Z→A and Sort keys A→Z (nested).
Dedupe
Tools → Dedupe removes duplicates from the active document: repeated records in JSON, NDJSON, YAML, XML and CSV, repeated lines in text. For a single array, open the tree's context menu on it and choose Remove nested duplicates. A notice tells you how many were removed.
Validate
JSON documents are checked as you type. Errors show as red markers in the editor and as Parse error · line N in the toolbar; the preview shows Preview unavailable until the document is valid again.