Skip to main content
Recursively filters out empty values from nested objects and arrays. This function removes the following empty values:
  • None values
  • Empty strings (after trimming whitespace)
  • Empty lists
  • Empty dictionaries
  • Lists and dictionaries that become empty after filtering their contents

Examples

Arguments

data
T
required
The data structure to filter (dict, list, or any other type)

Returns: T

Filtered data structure with empty values removed