Skip to content
SDETRole
SDETRole

JSON & Data

JSON Minifier

Strip whitespace from JSON and see the size saving.

Runs entirely in your browser No sign-up

Input JSON

0 chars

Minified

About this tool

Minified JSON is handy when you need a payload on one line: a cURL command, a CI environment variable, a CSV cell or a query parameter. The minifier validates the input first, so you never ship a broken payload, and shows the size before and after. It parses with the browser’s own JSON parser and re-serialises without whitespace, so the output is exactly what JSON.stringify would produce.

How to use it

  1. Paste formatted JSON, or load the sample.
  2. Check the banner: invalid JSON is reported with its location instead of being minified.
  3. Copy the single-line output or download it as a file. The green banner shows the size before and after.

When testers need minified JSON

  • Request bodies in cURL commands, where a one-line -d '{...}' is easier to paste and share.
  • CI secrets and environment variables that hold JSON, such as a service-account key or a feature-flag map.
  • Data-driven tests that keep a JSON payload in a single CSV or spreadsheet cell.
  • Query parameters that carry JSON. Minify first, then URL-encode the result.
  • Log lines and NDJSON files, which expect exactly one JSON document per line.

Minifying is not compression

Over HTTP, responses are usually compressed with gzip or Brotli, and whitespace compresses extremely well. Minifying a response saves far less on the wire than the byte count here suggests. Minification matters most where JSON is stored or pasted uncompressed: environment variables, database columns, URLs and fixtures checked into a repository.

Minifying JSON from code and the command line

  • JavaScript: JSON.stringify(JSON.parse(text)).
  • Python: json.dumps(obj, separators=(",", ":")). The default separators add a space after commas and colons.
  • jq: jq -c . payload.json prints compact output.
  • Java with Jackson: new ObjectMapper().writeValueAsString(obj) is compact by default.

JSON Minifier FAQ

Does minifying change any values?

No. Only whitespace between tokens is removed. Whitespace inside string values is preserved exactly. One caveat: integers larger than 2^53 − 1 are rounded by any JavaScript-based parser, including this one, so keep very large IDs as strings.

Can I minify JSON that contains comments?

No. Comments are not valid JSON, so the input is rejected. Remove the comments first. If the file is JSONC (for example a VS Code settings file), the tool that reads it must support comments explicitly.

Is the output safe to paste into a shell command?

Not automatically. Inside a single-quoted shell string, any single quote in your data must be escaped. The cURL Command Generator builds the quoting for you.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →