JSON formatter

Pretty-print JSON with your choice of indentation, optionally sorting keys.

Input

The JSON to format.
Spaces per indentation level.
Sort object keys alphabetically.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/json-format \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"{\"b\":1,\"a\":[1,2]}"}}'
import json, urllib.request

body = {'input': {'text': '{"b":1,"a":[1,2]}'}}
request = urllib.request.Request("https://setget.net/v1/tools/json-format", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/json-format", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"{\"b\":1,\"a\":[1,2]}"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "json-format",
  "input": {
    "text": "{\"b\":1,\"a\":[1,2]}"
  }
}
{
  "input": {
    "text": "{\"b\":1,\"a\":[1,2]}"
  }
}

Endpoint: POST /v1/tools/json-format. Over MCP: run_tool with slug: "json-format". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
text string yes The JSON to format.
indent integer no Spaces per indentation level. Default: 2. From 1 to 8.
sort_keys boolean no Sort object keys alphabetically. Default: false.

Examples

Input
{
  "text": "{\"b\":1,\"a\":[1,2]}"
}
Result
{
  "text": "{\n  \"b\": 1,\n  \"a\": [\n    1,\n    2\n  ]\n}"
}

Sorted keys, four spaces

Input
{
  "text": "{\"b\":1,\"a\":2}",
  "sort_keys": true,
  "indent": 4
}
Result
{
  "text": "{\n    \"a\": 2,\n    \"b\": 1\n}"
}

Questions

Does formatting change my data?
No. Only whitespace changes, and key order if you ask for sorting.
What happens if the JSON is broken?
You get the line and column of the first fault, so you can fix it.