Format JSON
Try it interactively →POST /api/json-formatFormat JSON: pretty-print with indent, minify whitespace, or sort keys lexicographically (deterministic output for hashing & diffs).
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| input* | string | — | JSON text. |
| mode | enum (pretty | minify | sort) | "pretty" | Output mode. |
| indent | number (1…8) | 2 | Indent width in spaces (ignored for `minify`). |
Response
Modes: json, text. Cache: yes (24h TTL).
Code samples
Built from the sort-small example.
curl -X POST https://api.xtract.bot/api/json-format \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"input": "{\"zebra\":1,\"alpha\":{\"y\":2,\"x\":3},\"mid\":[1,2,3]}",
"mode": "sort",
"indent": 2
}'