---
title: compact
categories: |
filters
version: 0.104.0
filters: |
Creates a table with non-empty rows.
usage: |
Creates a table with non-empty rows.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->
# `compact` for [filters](/commands/categories/filters.md)
<div class='command-title'>Creates a table with non-empty rows.</div>
## Signature
```> compact {flags} ...rest```
## Flags
- `--empty, -e`: also compact empty items like "", {}, and []
## Parameters
- `...rest`: The columns to compact from the table.
## Input/output types:
| input | output |
| --------- | --------- |
| list\<any\> | list\<any\> |
## Examples
Filter out all records where 'Hello' is null
```nu
> [["Hello" "World"]; [null 3]] | compact Hello
╭────────────╮
│ empty list │
╰────────────╯
```
Filter out all records where 'World' is null
```nu
> [["Hello" "World"]; [null 3]] | compact World
╭───┬───────┬───────╮
│ # │ Hello │ World │
├───┼───────┼───────┤
│ 0 │ │ 3 │
╰───┴───────┴───────╯
```
Filter out all instances of null from a list
```nu
> [1, null, 2] | compact
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
╰───┴───╯
```
Filter out all instances of null and empty items from a list
```nu
> [1, null, 2, "", 3, [], 4, {}, 5] | compact --empty
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
│ 3 │ 4 │
│ 4 │ 5 │
╰───┴───╯
```