How to remove JSON properties that are nulls

If you have a JSON object that has properties that are null and you want to remove all of them, then you can do the following:

  • Format the JSON for readability - this will put one property per line
  • Remove lines that contain "null" or ":null" (for better reliability)
  • Take care of potentially "hanging" commas that may appear if the deleted property is the last in an object
  • Concatenate all the rows back into one JSON object

Here is a sample project that does that:

remove-null-properties.zip (2.1 KB)

:warning: In the example the column [prev line] actually means the "next line" despite its name. I was too lazy to redo the example.