Minify JSON
Squeeze indented data into the smallest form that still means the same: in the example, four lines with a, b and a short list come back as one line with no spaces at all, every name and value intact. 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.
strip whitespace, free in your browser
Where the extra bytes come from
Data that looks good in an editor, with two-space indentation, a line break after every entry and a blank line between sections, carries dead weight once it leaves the place where it was written. A configuration file, a response kept in a cache close to visitors, or data bundled into a mobile app all pay for that formatting: more bytes to transfer, more bytes to read and more bytes sitting in storage. None of those spaces changes what the data means, so removing them costs nothing in meaning and saves space everywhere the data goes.
What minifying does, step by step
First the whole text is read to confirm that it is valid. Then it is written back with every non-essential space removed: no indentation, no line breaks and no space after colons or commas, so the entire structure fits on one compact line while every name, value and level stays exactly where it was. In the example, four indented lines become a single line. Keep the readable version as your source, because the compact one is meant for machines, and you can always lay it out again for people with a formatter.
FAQ
How much smaller does the file get?
It depends on how much whitespace the original had; a heavily indented, deeply nested file often shrinks noticeably, while an already compact file sees a smaller reduction.
Does minifying change my data?
No. Every name, value and level of nesting stays exactly as it was; only indentation, line breaks and the spaces after colons and commas disappear. In the example, a still holds 1 and b still holds the list with 1 and 2.
Can minified data be made readable again?
Yes. Nothing is lost when the spacing is removed, so formatting the compact line again restores a readable, indented layout at any time. Keep the readable version as your working copy and publish the compact one.
Does it check that my data is valid?
Yes. The whole text is read first, as strictly as a program would read it, and only valid data is compacted. Broken data, such as a missing quote or a stray comma, is reported instead of being squeezed into a broken line.
When is it worth minifying data?
Whenever the data travels or is stored many times: a configuration file, a response kept in a cache, or data bundled inside a mobile app. Each of them pays for every extra byte when it is transferred, read and stored.
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-minify \
-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-minify", {
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-minify",
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-minify", 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-minify", 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_minify",
"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
Every space, newline, and tab left inside a JSON file is a byte that travels over the wire for no functional reason, and at scale that adds up to real bandwidth and parsing cost. This JSON minifier API removes all of it in one call, turning a nicely indented development file into the smallest valid JSON that represents the same data.
The cost of shipping pretty JSON
None of the whitespace changes what the data means, so removing it is pure upside. JSON that looks great in an editor — two-space indentation, line breaks after every property, a blank line between sections — carries a meaningful amount of dead weight once it leaves the development environment. A configuration file, a static API response cached at the edge, or a mobile app's bundled data payload all pay a real cost for that formatting: more bytes to transfer, more bytes to parse, and more bytes sitting in a content delivery cache.
What happens when you call the endpoint
You call POST /data/json-minify and receive a task_id immediately, since minification runs asynchronously. The service parses your JSON to confirm it is valid, then re-serializes it with every non-essential whitespace character removed — no indentation, no line breaks, no space after colons or commas — collapsing the entire structure onto a single compact line while keeping every key, value, and nesting level exactly intact.
Why minification became standard practice
As JSON replaced XML as the default data-interchange format on the web, developers inherited a lesson already learned from CSS and JavaScript: source formatting is for humans, and shipped formatting is for machines, and conflating the two wastes bandwidth for no readability benefit once code is in production. Minification tools for JSON emerged for the same reason minifiers exist for those other formats — the data itself never needed the whitespace, only the person editing it did.
Where minification belongs in a pipeline
Keep the readable, formatted version in your source repository and generate the minified version as a build step, so developers always work with something legible while production only ever sees the compact form. Use this step at the very last moment before data leaves your system: right before caching an API response, embedding a JSON payload inside an HTML page, storing a compact snapshot, or sending a webhook body where every byte counts against a size limit.
Delivery, pricing, and status
The minified JSON is delivered by a signed webhook, recommended for build 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 input size, and a failed task — such as malformed JSON that fails to parse — is never charged after the standard three retries. This endpoint is live now.
Integration use cases
Shrink cached API responses
Minify JSON responses before caching them at the edge, cutting transfer size for every client that hits the cache without changing a single value.
Reduce mobile app bundle weight
Strip whitespace from bundled configuration or localization JSON before packaging a mobile release, shaving download size across every install.
Fit payloads under webhook size limits
Minify an outgoing webhook body before sending it to a third-party endpoint with a strict payload size cap, avoiding rejected deliveries.
Compact data before embedding in HTML
Minify a JSON blob before inlining it into a script tag on a server-rendered page, keeping page weight down without touching the data itself.
Technical questions
How do I minify JSON with an API?
Send your JSON body to POST /data/json-minify, which returns a task_id right away; the compacted result arrives at your signed webhook or a signed link once the job finishes.
Is the JSON minifier 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 minifying JSON change the data itself?
No. Only whitespace is removed — indentation, line breaks, and spaces around punctuation — while every key, value, and nesting level stays exactly as parsed.
Can I minify very large JSON payloads?
Yes, within the size limits published for the endpoint; since pricing is a flat fee per request, cost stays predictable no matter how large a valid payload is.
What happens if my JSON is invalid?
The task fails with a clear parsing error after the standard three retries, and you are not charged for it.
Can I minify JSON in bulk?
Yes. Each request is an independent asynchronous task, so you can submit large batches in parallel and collect each minified result by webhook as it completes.
Should I keep a formatted copy of my JSON?
Yes — keep the readable, indented version in your source repository and generate the minified version as a build or deploy step, so developers still work with something legible.