JSON Cleaner

Drop the nulls, blank strings and empty containers that a serialiser left behind, and keep only the fields that carry data.

JSON
Cleaned JSON
Runs locally in your browser

About the JSON Cleaner

Payloads that come out of an ORM or a form submission are usually padded with fields nobody set: null placeholders, empty strings where a user skipped an optional box, and empty arrays for relations that were never loaded. This cleaner walks the whole document from the leaves upward and removes those values according to the four switches above, so a nested object whose last useful key disappears is removed as well rather than left behind as {}.

Each rule can be turned off on its own. Turn off "Drop null values" when null is meaningful in your schema, for example when it marks a field that was deliberately cleared rather than never filled. Keep "Trim spaces around strings" on when data came from a spreadsheet paste, since values there often carry a trailing space that breaks equality checks later.

The status line reports how many values were removed, which is a quick way to judge how much padding a response carries. Key order and every remaining value are untouched: numbers are not rounded, booleans stay booleans, and false or 0 are never treated as empty because they are real data.

Once the fixture is trimmed, the JSON Minifier squeezes out the remaining whitespace, and the JSON Diff shows exactly which keys the cleaning step took away.

How to use

  1. Paste your JSON on the left, or press Sample to load an example with nulls and blanks in it.
  2. Tick or untick the four rules until the right pane keeps what you need. Every change re-runs immediately.
  3. Read the status line to see how many values were dropped.
  4. Click Copy or Download to save cleaned.json.

Common questions

Does the cleaner remove keys whose value is false or zero?
No. Only null, empty strings and empty containers count as empty here, because false and 0 are values a program can act on.
What happens to an object once all of its keys are removed?
It is removed too, as long as "Drop empty objects and arrays" is ticked. The removal bubbles up level by level, so an empty branch never survives as a stub.
Can I keep nulls but still delete blank strings?
Yes. Untick "Drop null values" and leave "Drop empty strings" ticked; the rules are applied independently on every pass.
Is the order of my keys preserved?
Yes, keys come out in the order they went in. Use the JSON Sorter if you want them alphabetical instead.