How to Minify JSON for API Requests

Minify JSON without changing string spaces or large integer values. See a before-and-after example and API validation checks.

JSON minification removes whitespace outside quoted strings. It does not shorten field names, remove records or encrypt values. Use a compact copy for transport while keeping readable source data for maintenance.

A before-and-after example

Paste this synthetic example into the JSON Minifier:

{
  "customer": "Ada Example",
  "items": [1, 2],
  "note": "keep  two spaces"
}

The expected output is:

{"customer":"Ada Example","items":[1,2],"note":"keep  two spaces"}

The two spaces inside the note are retained because they belong to the value. The line breaks and indentation outside strings disappear. Save this example as a regression check when changing a minification workflow.

Large identifiers must stay exact

A parse-and-reserialize workflow can round numbers larger than JavaScript's safe integer range. ToolVero validates syntax and then removes whitespace from the original text outside strings; it does not regenerate numeric values from parsed JavaScript numbers. For example, { "id": 9007199254740993 } must become {"id":9007199254740993}. This does not control how the receiving API parses the number. Use string identifiers when that API requires them.

Syntax validation is only the first check

Comments, trailing commas and single-quoted keys are not standard JSON. Fix those errors before minifying. A valid document can still have the wrong fields or types: "quantity":"2" is a string whereas "quantity":2 is a number. Compare the payload against the API's schema and required fields. Avoid duplicate keys because different consumers may interpret them differently.

Before sending the request

  1. Keep the readable source and work on a copy.
  2. Minify and use the JSON Validator for a syntax check.
  3. Compare identifiers, array lengths, booleans, nulls and strings with the source.
  4. Send a non-sensitive test payload to your own test environment before using production data.

Minification is separate from HTTP compression such as gzip. Measure the actual request size if a service has a payload limit; whitespace savings depend on how much formatting the original contained. Never treat minification as a way to hide API keys or personal data.

Put this guide into practice

Explore all developer tools · See complete workflows