Search

Dark theme | Light theme

November 29, 2026

Nushell Niceties: Transform A Table Into Markdown Markup Table

Nushell has built-in support for creating Markdown markup. The to md command can turn several Nushell data structures to Markdown. One of them is the Nushell table. The output is Markdown markup of a table with the contents of the Nushell table. You can add the option --pretty (or shorter option -p) to have a vertically aligned Markdown table, which gives a more readable Markdown table. Finally you can make certain columns of the table centered horizontally by specifying the --center option.

The following example shows how to turn a Nushell table into a Markdown table using several extra options:

use std/assert

# Sample table with 2 columns and 2 rows.
let table = [[a b];
  [1 2]
  [1 3]
]

# Using to md to turn a a table into a Markdown table.
(assert equal ($table | to md)
  ("
| a | b |
| --- | --- |
| 1 | 2 |
| 1 | 3 |" | str trim))

# Using to md --pretty (or -p) to turn a a table into
# vertically aligned Markdown table.
(assert equal ($table | to md --pretty)
  ("
| a   | b   |
| --- | --- |
| 1   | 2   |
| 1   | 3   |" | str trim))

# Using to md --center to turn one or more columns
# into a Markdown table with centered columns.
(assert equal ($table | to md -p --center [a b])
  ("
|  a  |  b  |
|:---:|:---:|
|  1  |  2  |
|  1  |  3  |" | str trim))

Written with Nushell 0.117.0.