JSON Cleaner

Drop null fields, blank strings, empty arrays from a JSON payload. Every removal lands in a path log under the editors, so you see what left before you ship the result.

Before0UTF-8 bytes, same indent
After0
Values removed0Trims not included

Source JSON

Cleaned JSON

Waiting

Removal log

Paste JSON on the left. The log fills in as rules match.

No rows yet.

One signup webhook, 12 removals

Press Load the signup webhook. The sample is a newsletter signup the way a form service posts one: a subscriber block, UTM tags, consent flags, plus the fields nobody filled in. With the three default rules on, the log lists 12 paths.

Removed

  • 6 nulls: subscriber.phone, subscriber.address.country, the three utm tags, unsubscribed_at
  • 3 empty strings: subscriber.company, subscriber.address.city, the blank fourth item in topics
  • 3 containers: subscriber.address and utm, both emptied by the rules above, plus attachments: []

Kept on purpose

  • "marketing": false, a recorded choice
  • "referrer_count": 0, a real count
  • "notes": " ", three spaces are text until Trim runs
  • The second "json" in topics
  • The padding around " Priya Raman "

At a 2-space indent the payload drops from 616 bytes to 381. The meter prints both sides at the indent you picked. The difference is removed values, not a whitespace change. Paste minified JSON, print the result pretty, and a naive counter would report a bigger file after cleaning.

Now tick Trim strings and Duplicates in arrays. The name loses its padding. notes trims down to "" and leaves under the empty string rule. The second "json" goes. The log grows to 15 rows.

What each rule removes, and where each one stops

Null values
Removes any key whose value is null, plus null items inside arrays. A protected key keeps its null.
Empty strings
Removes "" and nothing else. A value of spaces or a lone tab stays, unless Trim strings runs first and reduces the value to "".
Empty objects, arrays
Runs after the children are cleaned, so a block emptied by other rules goes too. subscriber.address held two blank fields and left with them. The top level is never removed. Clean {"a": null} and you get {}, not an empty file.
Trim strings
Strips whitespace from the start and end of string values. Keys stay as written. Spaces between words stay.
Duplicates in arrays
Compares items after cleaning, with object key order ignored. {"x":1,"y":2} and {"y":2,"x":1} count as one item. The first copy stays. "1" and 1 differ, since one is a string.
Sort keys A to Z
Orders by character code, so Zone sorts before apple. Keys made only of digits, such as "2024" or "10", print first in numeric order whether sorting is on or off. JavaScript objects store integer-like keys that way, and the cleaner works on a parsed object.

When null carries meaning

Most nulls in a payload mean "no value yet". Some formats treat null as an instruction, and cleaning those bodies changes what the request does.

JSON Merge Patch, RFC 7396. A null member means delete. Send {"phone": null} to an endpoint built on merge patch and the stored phone number is cleared.

Run the body through a cleaner first and the request becomes {}, an empty patch. The phone number stays on the record, and nobody gets an error.

Soft-delete fields such as deleted_at or unsubscribed_at follow the same pattern. So do OpenAPI schemas where a property is required but nullable. Remove the key and the validator rejects the record, even though the value was legal.

Type those names into Protected keys, comma separated. Their values survive at any depth, null or blank. Items inside a protected array or object still go through the rules. Protection matches the key name, not a full path, so protecting id protects every id in the file.

No "remove undefined" switch, on purpose

JSON has six kinds of value: object, array, string, number, true or false, and null. undefined is a JavaScript value. JSON.stringify drops undefined before any JSON text exists, so a pasted document never contains one. An undefined toggle on a JSON cleaner switches nothing. The earlier version of this page had one. The switch is gone.

There is no switch for false or 0 either. A subscriber who declined marketing email is false. A referrer count of zero is a measurement. Removing either one edits the data, and a reader of the cleaned file would read the gap as "unknown".

Limits before you paste production data

Check the result against the original

The log names each path removed. For both documents side by side, paste the source and the cleaned output into JSON Diff. Want keys reordered with no values removed? Use the JSON Sorter. Want a smaller file with every value intact? The minifier removes whitespace and touches nothing else.

Questions after the first clean

Missing blocks, kept zeros, changed ids, moved keys.

Does the cleaner remove false or 0?

No. False and 0 are data, not blanks. The rules target null, the empty string, and empty objects or arrays. There is no switch for false or 0.

A whole object disappeared. Why?

Every field inside the object was null or blank. The other rules emptied the object, then the empty container rule removed the shell. The log shows the object path with the note "after other rules". Untick Empty objects, arrays to keep it as {}.

How do I keep one null field?

Type its key name into Protected keys. The value stays, null or blank, wherever the key appears. Separate several names with commas.

Why did a long id change?

Cleaning parses the JSON into JavaScript numbers, which keep about 15 to 16 digits exact. 1234567890123456789 becomes 1234567890123456800. The page shows a warning when this happens. Store such ids as strings.

Why did number-like keys move to the top?

JavaScript objects list keys such as "10" or "2024" first, in numeric order, ahead of every other key. The cleaner works on a parsed object, so those keys move even with sorting off.

Is my JSON sent anywhere?

No. The cleaning, the byte count, copy and download all happen in your browser tab.