title: "Types" sidebar_position: 4
Types
Each nushell type
becomes a cell of a kind a spreadsheet can work with, and goes back to
the same type. A file size is a number of bytes in the Size format, so
=SUM adds it and where size > 1kb still compares it once it's back
in nushell (sheet is 012 as a stage
of a pipeline):
ls | select name size | sheet | describe
# table<name: string, size: filesize>
This holds wherever NUON carries a table: pipelines,
notebook cells and their outputs sent to sheets, .nuon files opened, imported or
downloaded, and linked .nuon files.
| Nushell | Cell | Sent back as |
|---|---|---|
| int, float | A number | An int when whole, a float otherwise |
| string | Text, kept as text even when it looks like a number ("12") |
A string |
| bool | TRUE or FALSE | A bool |
| null | A blank cell | null |
filesize (1646b) |
The number of bytes, in the Size format: 1.6 kB |
A filesize, from any number in the Size format |
duration (90sec) |
Elapsed time, in the Duration format: 0:01:30, with milliseconds (0:00:01.500) when there are fractions of a second |
A duration, from any number in the Duration format |
| datetime | A date and time in the local time zone, in the Date time format | A datetime with the local offset, to the microsecond, from any number in a date or date-time format; a time of day alone is a duration since midnight |
| list, record | Their NUON text: [a, b], {k: 1} |
The list or record again, when the text is still exactly NUON |
| binary | Its NUON text, 0x[DEAD] |
Binary again, as lists and records |
Since the types are the cells' formats, formatting a column in 012 decides what goes back: numbers given the Size format go back as file sizes, and a date column formatted as plain numbers goes back as numbers.
Currency and percentages
Nushell has no type for money or percentages, so $3.50 goes to
nushell as the number 3.5 and 12% as 0.12, which math sum and
where price > 3 work on. The format comes back with the column: when
a notebook cell's output is sent to a sheet, each of
its columns named as a column of the ranges the cell read
($sheet.A1:C9, $selection) takes that column's format again, when
its values are still of the type the format shows. A price column read
as currency and sent back is currency, a date column shows its dates
in its own pattern (2026-09-29 rather than the Date time format), and
a size column keeps its decimals:
$sheet.A1:D9 | where price > 3 | sort-by bought # price is currency again on the sheet
A column named anew (insert total {|r| $r.price * $r.qty}) has no
format to take, and shows plain numbers. Outside notebooks, 012 get --format json
keeps currency and percentages as typed values.
Tables, records and single values
A value that isn't in a table comes in as a table too: a
record is one
row (sys host), and a list of values that aren't records is one
column named value. Errors in cells go out as their text
("#DIV/).
JSON
JSON has fewer types, so a table sent as JSON (--to json, or a table
that came in as JSON) carries numbers, booleans, text and null as
themselves, file sizes as bytes, durations as nanoseconds and dates as
RFC 3339 text, as nushell's
to json does.
Use NUON to keep the types.
What doesn't survive the trip
- An empty string comes back as null: both are a blank cell.
- A whole float such as
2.0comes back as the int2. - Text with line breaks comes back on one line.
- Dates past the microsecond lose the rest: a cell's date is a count of days, which holds about that much.
- Nested values are text in the sheet, so formulas see their text, not
their contents. Flatten them in nushell first
(
flatten,selectwith a cell path) to work with them as columns.