Format API Response JSON — clean, trim, standardize

Strip the cruft out of REST, GraphQL, and webhook responses. Trim whitespace, sort keys, drop nulls, and standardize casing in one pass.

Paste your JSON → Get results instantly (no signup)

⚡ Instant resultsNo signupRuns in your browser
Try examples:

remove noisy values and remove nulls and empties.

{
"name": "Alice",
"bio": "",
"age": 30,
"address": null,
"tags": [],
"meta": {}
}
Output
1{
2 "name": "Alice",
3 "age": 30
4}

Love the result?

Use this exact pipeline in your app, backend, or LLM workflow.

No setup needed. Works with curl, Node, Python.

Uses example data. For edited input, copy from the playground.

Read integration guide

Works with:

  • REST and GraphQL responses
  • Webhook payloads (Stripe, Shopify, GitHub)
  • Vendor SDK output
  • Sandbox vs production payload diffs

Example: input → output

Vendor APIs do not always return what their docs claim. A sandbox payload omits a field that production includes. A webhook from last week has six extra metadata keys nobody documented. A retry response wraps the same data one level deeper than the first attempt. By the time these reach your code, they are usually causing a mystery bug — fix once at the boundary instead.

The shape of API noise

Real-world API responses pick up cruft from a dozen places:

  • vendor SDKs that wrap the payload in their own envelope
  • sandbox-vs-production differences (sandbox emits demo placeholders, prod doesn't)
  • webhook retries that add attempt or idempotency_key fields not present on the first delivery
  • inconsistent casing across providers (customer_id here, customerId there)
  • explicit null placeholders for fields the user never filled in
  • whitespace artifacts from JSON-encoded user input

None of these are bugs in the API; they're the realities of an external integration. A normalization step at the boundary reduces every downstream consumer to handling one shape instead of N.

Workflow for a noisy response

  1. Paste the raw response into the input panel.
  2. Pick the cleanup options that match your downstream code's expectations: drop nulls, trim string whitespace, sort keys for stable diffs, normalize key casing.
  3. Run, copy, and feed the result into your test fixture, your replay tool, or your storage layer.

This is the same runner as the Clean JSON tool — the framing here is API-payload specific, but the engine is identical, so the cleanup is idempotent and pipeline-safe.

When this matters most

  • Webhook debugging — a payment provider's invoice.paid event looks different in test mode vs live mode. Strip the demo placeholders to see the real diff.
  • Vendor SDK normalization — wrap-style SDKs add metadata keys that aren't in the upstream API. Drop them before storing.
  • Contract testing — alphabetize keys so two sample payloads diff cleanly without false positives from key reorder.
  • Sandbox-vs-prod reconciliation — normalize both sides, then diff the result to see what actually changes between environments.
  • Vendor reconciliation reports — feed the cleaned payload into JSON to CSV for a finance-friendly review.

Pitfalls when normalizing API output

  • Lossy null-strip. Stripe and a handful of other providers use null to mean "explicitly cleared" — do not strip nulls when the downstream consumer needs that distinction.
  • Casing rename across SDKs. If you normalize keys to camelCase but downstream code references the snake_case originals (in tests, fixtures, or logs), the rename creates a second problem.
  • Trim across user-input fields. Whitespace inside a user's display name might be intentional. Trim leading/trailing only; do not collapse internal whitespace.
  • Order-sensitive consumers. If your storage layer or downstream pipeline preserves array order semantically (e.g. a list of events in chronological order), do not reorder arrays.

Format vs validate

Formatting cleans the shape; validation confirms it matches a contract. The two pair well — clean first to remove cosmetic noise, then run a JSON Schema Validator or the API/Webhook Payload Validator against the result. Or, if you only need to know whether the input parses at all, the JSON Validator covers the syntax case.

For shrinking the cleaned payload further before passing it into a model, see JSON for LLMs — same cleaning engine, prompt-budget framing.

Frequently asked questions

What does this tool do that a generic JSON formatter doesn't?+

It runs a cleanup pass shaped around real API noise: trimming whitespace from user-input fields, dropping null placeholders, sorting keys for diff stability, and standardizing casing. Pretty-printing alone doesn't fix any of those.

Is the cleanup idempotent?+

Yes. The same options applied twice produce the same output, so the formatter composes safely inside a pipeline or test fixture.

Can I keep null fields when the API uses them as 'cleared' signals?+

Yes. Null-strip is a toggle. Stripe and a few other providers use null to mean 'explicitly set to no value'; in that case, leave nulls in place.

Does this validate the response shape?+

No — formatting and validation are separate steps. After cleaning, run the JSON Schema Validator or the API/Webhook Payload Validator against the result if you also need a contract check.

Vendor-specific gotchas (Stripe, GitHub, Shopify)?+

Stripe uses null as a meaningful 'explicitly cleared' marker — do not strip nulls. GitHub webhooks include retry metadata that's safe to drop. Shopify sandbox payloads include demo placeholders that production omits — normalize before diffing across environments.

Related tools

Read more on the blog

Advanced usage (optional)

Clean Values

v1.0.0
Cleanup
objectarraydestructive

Description

Clean Values

Remove nulls, empty strings, empty collections, default values, and duplicates from JSON data. Optionally trim whitespace and sort keys. A comprehensive cleanup utility for normalizing messy data.

Operations

Each cleanup operation can be toggled independently. Enable multiple operations to clean data in a single pass.

Remove null values

Delete object keys that have null values at any depth.

Remove empty strings

Delete object keys that have empty string "" values.

Remove empty collections

Delete empty objects {} and empty arrays [].

Remove default values

Delete falsy defaults — 0 and false. Useful for stripping placeholder values.

Remove duplicates

Remove duplicate items in arrays. Compares both primitive values and full objects (deep equality).

Trim whitespace

Trim leading and trailing whitespace from all string values throughout the document.

Sort object keys

Sort object keys alphabetically at all levels.

Configuration

FieldTypeDefaultDescription
Apply topath-picker[]Scope operations to specific paths only (empty = apply everywhere)
Remove null valuesbooleantrueRemove object keys with null values
Remove empty stringsbooleantrueRemove object keys with empty string values
Trim whitespacebooleantrueTrim leading/trailing whitespace from strings
Remove empty collectionsbooleanfalseRemove empty objects {} and arrays []
Remove duplicatesbooleanfalseRemove duplicate items in arrays
Remove default valuesbooleanfalseRemove falsy defaults (0, false)
Sort object keysbooleantrueSort object keys alphabetically

Use Cases

API Response Cleanup

  • Strip null fields from API responses before displaying
  • Remove internal metadata fields (__v, _id) with empty values
  • Trim whitespace from user-submitted form data

Data Normalization

  • Deduplicate records imported from multiple sources
  • Sort keys for consistent ordering across objects
  • Remove placeholder defaults before exporting

Configuration

NameTypeDefaultDescription
Apply topath-picker[]Scope operations to specific paths only (empty = apply everywhere)
Remove null valuesbooleantrueRemove object keys that have null values
Remove empty stringsbooleantrueRemove object keys that have empty string values
Trim whitespacebooleantrueTrim leading and trailing whitespace from all string values
Remove empty collectionsbooleanfalseRemove empty objects {} and empty arrays []
Remove duplicatesbooleanfalseRemove duplicate items in arrays (primitives and objects)
Remove default valuesbooleanfalseRemove falsy defaults (0, false)
Sort object keysbooleantrueSort object keys alphabetically

Examples

AI Prompt
Clean up this JSON and remove noisy values and remove nulls and empties.
{
"name": "Alice",
"bio": "",
"age": 30,
"address": null,
"tags": [],
"meta": {}
}
Output
1{
2 "name": "Alice",
3 "age": 30
4}
Config
Remove null values
ON
Remove empty strings
ON
Trim whitespace
OFF
Remove empty collections
ON
Remove duplicates
OFF
Remove default values
OFF
Sort object keys
OFF

API Usage

POST /api/v1/utilities/cleanup.clean-json
Example:
curl -X POST https://your-domain.com/api/v1/utilities/cleanup.clean-json \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs":{"primary":{"name":"Alice","bio":"","age":30,"address":null,"tags":[],"meta":{}}},"config":{"removeNulls":true,"removeEmptyStrings":true,"removeEmptyCollections":true,"removeDefaults":false,"removeDuplicates":false,"trimStrings":false,"sortKeys":false}}'
Response
1{
2 "name": "Alice",
3 "age": 30
4}