Format JSON
Paste a squeezed line of data and get it back laid out level by level: in the example, b and a land on their own lines, the list under a is spread out, and the order stays exactly as it was. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
pretty-print online, free in your browser
Why indented data is easier to live with
Data squeezed onto one line, or indented differently by every tool that touched it, is hard to read in a review and noisy in a version history. A file saved by one program, edited by a script and committed by a third person tends to collect mixed spacing, so a one-line change can show up as a hundred-line difference simply because everything was re-indented. Laying the data out with a fixed number of spaces per level means the same content always looks the same, and the real change stands out.
How it works, and what it never changes
The tool first reads the entire text as strictly as a program would, then writes it back with the number of spaces you choose for each level, two unless you pick another value from 0 to 8. Entries keep their order, so in the example b still comes before a, and lists keep theirs too. Values and their kinds are untouched: text stays text, numbers stay numbers. Choosing zero gives the compact single-line form instead. If the text is broken, you are told so rather than given a guess, because repairing data is a different job.
FAQ
What does stable key ordering mean here?
Object keys are sorted alphabetically at every nesting level so the same logical data always produces byte-identical output, which keeps version-control diffs meaningful. Array element order is preserved as-is.
Can I choose how many spaces each level is indented?
Yes. Two spaces per level is the default, and you can pick any whole number from 0 to 8. Two or four are the usual choices for reading, while zero puts everything back on one compact line.
What happens if my data has a mistake in it?
The whole text is read strictly before anything is laid out, so broken data, such as a missing quote or a leftover comma, is reported instead of being turned into something misleading. Fix that spot and format again.
Why format data that already works?
Because one long line is hard to review: a single change can hide anywhere in it. Indented data shows one entry per line, so a person can read it in a code review, a support ticket or a log and see quickly what changed.
Are lists kept in their original order?
Yes. Lists keep their order, which usually carries meaning, and each item gets its own line when indentation is on. In the example, the list holding 1 and 2 is spread over two lines under a, in the same order.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/data/json-format \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"json":{"a":1}}'const res = await fetch("https://api.kit.forhosting.com/data/json-format", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"json": {
"a": 1
}
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/data/json-format",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"json": {
"a": 1
}
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/data/json-format", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"json":{"a":1}}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"json":{"a":1}}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/data/json-format", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"json": {
"a": 1
}
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "data.json_format",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 25 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Minified or inconsistently indented JSON is unreadable in a code review and unstable in version control, since two semantically identical objects can produce wildly different diffs. This JSON formatter API rewrites any payload with consistent indentation and, optionally, deterministic key ordering, so the same data always renders the same way.
Why unformatted JSON causes real problems
None of that breaks parsing, but it wrecks code review: a one-line change can show up as a hundred-line diff because a key moved position or the whole object got re-indented. A JSON file saved by one tool, edited by a script, and committed by a third person tends to accumulate inconsistent spacing, mixed tab and space indentation, and keys in whatever order the last serializer happened to emit them.
What the endpoint actually does
Arrays keep their original order, since array order is usually semantically meaningful, while only object keys are subject to stable sorting. You call POST /data/json-format with a JSON body and get a task_id back immediately, since formatting runs as an asynchronous job. The service parses the payload, re-serializes it with consistent, configurable indentation, and — when you request it — sorts object keys alphabetically at every nesting level, so the byte-for-byte output is identical every time the same logical data goes in.
Stable ordering and why it matters
The JSON specification never mandated a key order, which is technically correct but practically inconvenient: two libraries can serialize the exact same object with keys in a different sequence, and a naive text diff will flag that as a change even though nothing meaningful moved. Stable key ordering removes that ambiguity entirely, turning JSON into something that behaves like a normalized, comparable artifact rather than an unordered bag of properties that happens to look different every run.
Delivery, pricing, and status
The formatted JSON is delivered by a signed webhook, recommended for automated pipelines, or a signed link valid for 24 hours; source and output are deleted after the retention window and never used for training. Pricing is a flat $0.002 per request regardless of payload size, and a failed task — for instance, invalid JSON that cannot be parsed — is never charged after the standard three retries. This endpoint is live now.
Integration use cases
Clean diffs on generated configuration
Run auto-generated JSON config through the formatter with stable key ordering before committing it, so pull requests show only the lines that actually changed.
Normalize API fixtures for testing
Format captured API responses consistently so test fixtures stay comparable across recordings taken from different client libraries or SDK versions.
Prepare payloads for human review
Pretty-print a compact webhook payload before displaying it in an internal dashboard or support ticket, turning a dense single line into something a teammate can actually read.
Standardize exported data snapshots
Format nightly JSON exports with the same indentation and key order every time, making it trivial to spot what actually changed between two dates.
Technical questions
How do I format JSON with an API?
Send your JSON body to POST /data/json-format, which returns a task_id right away; the pretty-printed result arrives at your signed webhook or a signed link once the job finishes.
Is the JSON formatter API free?
The tool above runs free in your browser. The API is paid — each call draws from your prepaid ForHosting KIT balance: top up from $10.00 (it never expires), pay each request's published price, and a call with no balance returns HTTP 402. No subscription, no tokens, and a failed task is never charged.
Does formatting change my data or types?
No. Only whitespace, indentation, and optionally key order change; string, number, boolean, and null values are preserved exactly as parsed.
Can I format very large JSON files?
Yes, within the size limits published for the endpoint; because pricing is a flat fee per request, cost stays predictable regardless of how large a valid payload is.
What happens if the input isn't valid JSON?
The task fails with a clear parsing error after the standard three retries, and you are not charged for it.
Can I format JSON in bulk?
Yes. Each request is an independent asynchronous task, so you can submit large batches in parallel and collect each result by webhook as it completes.
How is this different from the JSON minifier?
The formatter expands JSON for readability with indentation and stable key order; the minifier does the opposite, stripping whitespace for the smallest possible payload.