Developer Formatting

JSON empty value remover

What to do

Processed in your browser · nothing is uploaded

Local · false and 0 are kept
Advertisement
320 × 100

Strips null, empty strings, empty arrays and empty objects recursively — so a branch left empty because its contents were removed is removed too.

How to use the json empty value remover

1 Paste the JSON.
2 Null, empty strings, empty arrays and empty objects go at every level.
3 false and 0 stay. They are values, not emptiness.
4 Copy the result, or save it as a file.

Recursion is the part naive implementations skip: removing a null inside an object can leave that object empty, and leaving the husk behind defeats the purpose. Working bottom-up handles it, and if the whole document empties out you get {} rather than nothing, so the result is still valid JSON.

What counts as empty is a judgement, and this one is drawn deliberately narrowly. Null and the empty string go. false, 0 and a string of spaces all stay: the first two because dropping a meaningful value is a real bug, the third because trimming is a different operation with different consequences and should be a decision you make on purpose.

The sharp edge is arrays. Removing a null from the middle of one closes the gap, so [1, null, 3] becomes [1, 3] and everything after the removal shifts down an index. If positions carry meaning. A fixed-width row, two arrays read in parallel, an index stored somewhere else. This rewrites your data rather than tidying it, silently and everywhere at once.

The same caution applies to null itself. Plenty of APIs distinguish "field absent" from "field explicitly null", the second meaning clear this value. Running a PATCH body through here turns every deliberate null into an omission, which is the opposite instruction.

Questions

No. Those are meaningful values. Only null, empty strings and empty containers go.

ECMA-404; the JSON data interchange syntaxMDN, JSON.parse()
Advertisement
300 × 250
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding