CSV and TSV as a table
.csv/.tsv files open as a table on the blob page (src/web/render/csv.ts, parser in csv-parse.ts).
RFC 4180 with quotes, embedded newlines, doubled quotes and a BOM; the delimiter (, ; tab |) is detected from the first record.
The first 1,000 rows are drawn on the server with a sticky header and (on phones) a sticky first column; numeric columns are right-aligned.
?all=1 ("Show all N rows", no JavaScript needed) draws up to 20,000. The header line shows rows × columns and the delimiter.
A small script adds a filter box over the rows drawn; no library.
A file that is not valid CSV shows the source with a one-line reason. ?view=source, Raw and Download work as for any file.
Sorting
A column header is a link: ?sort=<column>&dir=asc|desc on the blob page, so a sorted table has an address and works without JavaScript.
Clicking a header sorts ascending; clicking the sorted header flips it. The sorted header shows an arrow and aria-sort.
sortmust name a header cell exactly. A name that matches nothing, or adirthat is notasc/desc, is ignored (no sort, ascending): such a request reads the same rows and is kept under the same key as the page without it.- Only a matching sort reads past the 1,000-row window: it sorts every row the page may draw (up to 20,000) and then cuts the window, so the first rows shown are the top of the whole file.
- Numeric columns sort by value, others by lowercase text; empty cells, and cells that are not numbers in a numeric column, go last either way; ties keep file order.
- "Show all N rows" and every header link carry the sort (and
all=1). - The sort is server-side: the in-browser sort script is gone, and so is its filter-after-sort interplay; the filter still works over the rows drawn.
- The same sort works on
.jsonl/.ndjsontables. - The header is the design system's sortable table (
.table[data-sortable], its arrows incomponents.ts); the link covers the whole header cell, 44px tall under a coarse pointer. - Cost: a real sort parses up to 20,000 rows on the request's thread, once for each column and direction asked, then the page is kept; the distinct pages are bounded by the header's width (at most 200 columns, two directions).
In the terminal, on a .csv/.tsv open in the workspace, o orders the rows: file order, then each column ascending and descending in turn (the header shows ▲/▼), then file order again. It uses the page's sortRows (src/text/csv-sort.ts); s still flips to the source, which is never reordered.
JSON Lines
.jsonl/.ndjson files use the same table (src/web/render/jsonl-parse.ts makes the rows; csv.ts draws them).
- Columns are the union of the keys of the first 1,000 objects, in first-seen order; a key first seen later is not a column.
- Strings show as they are,
nullas empty, nested values as compact JSON; everything is escaped. - A line that does not parse is one row,
Line N: not valid JSON, orLine N: not a JSON objectfor valid JSON that is not an object (N counts physical lines). The rest of the file still renders. - The header line says
JSON Linesin place of the delimiter. A file with no non-blank lines falls back to the source view. - At most 200 columns are drawn; the page says how many there are.
Files over 5 MB
A table file over the render cap is not refused: a reader that draws (the page, the terminal workspace) asks the source for a prefix (blob(ref, path, { prefix: true })); the source reads its first bytes (CSV_PREFIX_BYTES) cut at a whole line and marks the blob partial. Only a partial blob lifts the table's RENDER_CAP; an editor or any other reader asks for no prefix and gets too_large as before, so a cut file is never saved.
- The page's cut inside a quoted field drops that record: one pass finds the last line end outside any quote (
safeLines). - The note under the table is one sentence:
Showing N of about M rows. The rest is in the raw file.M is the prefix's row density over the whole file size, so it is an estimate; the header line saysabout M rows. - Sorting and
?all=1work over the prefix only. Raw and Download still give the whole file. - The terminal workspace opens the same prefix for a
.csv/.tsv, says so in a toast (Showing the first X of Y, read-only. The rest is in the raw file.) and refuseseand the external editor on it.