> ## Documentation Index
> Fetch the complete documentation index at: https://intunedhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# filterEmptyValues

Recursively filters out empty values from nested objects and arrays.

This function removes the following empty values:

* `null` and `undefined` values
* Empty strings (after trimming whitespace)
* Empty arrays
* Empty objects
* Arrays and objects that become empty after filtering their contents

```typescript theme={null}
export declare function filterEmptyValues<T>(input: { data: T }): T;
```

## Examples

<CodeGroup>
  ```typescript Basic Usage theme={null}
  import { filterEmptyValues } from "@intuned/browser";
  import { BrowserContext, Page } from "playwright";

  interface Params {}

  export default async function handler(
    params: Params,
    page: Page,
    context: BrowserContext
  ) {
    // Filter empty values from dictionary
    const result1 = filterEmptyValues({ data: { a: "", b: "hello", c: null } });
    // Output: { b: "hello" }
    console.log(result1);

    // Filter empty values from list
    const result2 = filterEmptyValues({ data: [1, "", null, [2, ""]] });
    // Output: [1, [2]]
    console.log(result2);

    // Filter nested structures
    const result3 = filterEmptyValues({
      data: { users: [{ name: "" }, { name: "John" }] },
    });
    // Output: { users: [{ name: "John" }] }
    console.log(result3);
    return "All data filtered successfully";
  }
  ```
</CodeGroup>

## Arguments

<ResponseField name="input" type="Object" required>
  The input object containing the data to filter

  <Expandable title="properties" defaultOpen>
    <ResponseField name="input.data" type="T" required>
      The data structure to filter (object, array, or any other type)
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns: `T`

Filtered data structure with empty values removed
