JSON Cleaner
This JSON cleaner removes the values that carry no information — nulls, empty strings, empty arrays and empty objects — leaving a document that contains only real data. That matters more than tidiness: an API response is frequently mostly absent fields, and comparing two of them, storing them, or reading one by eye is far easier once the noise is gone. Removal repeats until nothing more is found, because emptying an object can leave its parent empty too, and a single pass would clear one layer and stop. Strings can be trimmed and keys sorted at the same time, which makes two documents directly comparable.
How it works
Removes nulls, empty strings, empty arrays and empty objects from a document, so what is left is the data that actually carries information. Useful before diffing two payloads, or before storing a response that is mostly absent fields.
Removal repeats until nothing more is found, because emptying an object can leave its parent empty too. A single pass would clear one layer and stop.
Everything runs in your browser — nothing you paste is sent to a server.
Why it is worth doing
- Diffing — two responses that differ only in which optional fields are null produce an enormous diff for no reason.
- Storage — nulls and empty containers cost space in every record.
- Reading — a 200-line response with 30 lines of actual data is far easier to read once the rest is gone.
- Fixtures — a test fixture full of nulls hides what the test actually depends on.
One caveat worth knowing
In some APIs, sending "field": null means "clear this value" while omitting the key means "leave it
unchanged". Those are different requests. Cleaning a payload before sending it can therefore change what it does —
check the API's semantics first.
Sorting keys
JSON object keys have no defined order, so two documents holding identical data can serialise differently. Sorting both puts them in a canonical form, at which point a plain text diff shows only real changes.
Frequently asked questions
What does the JSON cleaner remove?
Nulls, empty strings, empty arrays and empty objects — each a separate option, so you choose what counts as noise.
Why does removal repeat?
Emptying an object can leave its parent empty. A single pass would clear one layer and stop, so the process repeats until the count stops changing.
Why sort the keys?
Two documents with the same data but different key order look completely different in a text diff. Sorting both makes a diff show only genuine changes.
Is removing nulls always safe?
Not always. In some APIs an explicit null means "clear this field" while an absent key means "leave it alone" — check what the consumer expects before sending cleaned data.
Does it change my values?
Only if you turn on string trimming, which removes leading and trailing whitespace. Everything else is either kept exactly or removed.
Is my data uploaded?
No. Cleaning runs entirely in your browser.
Related tools
JSON Formatter & Beautifier
This JSON formatter beautifies minified or messy JSON online with clean indentation, line numbers, and code folding.
JSON Fixer & Repair Tool
This JSON fixer repairs comments, single quotes, trailing commas and unquoted keys.
JSON Sorter
This JSON sorter alphabetises object keys at every level of nesting so two files diff cleanly.