Skip to main content

Output Formats

Control output format with the --format / -F global flag, available on all commands.

lynxdb query 'level=error | stats count by source' --format table
lynxdb query 'level=error | stats count by source' -F csv

Format Reference

FormatDescriptionAuto-selected when
autoAuto-detect based on context (default)Always the default
jsonNewline-delimited JSON, one object per linePipe (non-TTY) output
ndjsonAlias for jsonNever auto-selected
tableBox table with headersTTY output with multiple columns
boxBox table with headersNever auto-selected
asciiASCII table for terminals without box drawingNever auto-selected
markdownMarkdown tableNever auto-selected
verticalOne record per block, one field per lineNever auto-selected
lineAlias for verticalNever auto-selected
GAlias for verticalNever auto-selected
csvRFC 4180 CSV with header rowNever auto-selected
tsvTab-separated values with header rowNever auto-selected
raw_raw field value per line, or tab-separated k=vNever auto-selected

Auto Behavior

The default --format auto adapts based on context:

ContextBehavior
TTY + single scalar resultPlain value (just the number or string)
TTY + multiple resultsHuman table
Non-TTY (pipe)json (one JSON object per line)

Examples by Format

json and ndjson

lynxdb query 'level=error | stats count by source' --format json
{"source":"nginx","count":340}
{"source":"api-gateway","count":120}

ndjson uses the same byte format:

lynxdb query 'level=error | stats count by source' --format ndjson
{"source":"nginx","count":340}
{"source":"api-gateway","count":120}

table

lynxdb query 'level=error | stats count by source' --format table
┌─────────────┬───────┐
│ source │ count │
├─────────────┼───────┤
│ nginx │ 340 │
│ api-gateway │ 120 │
└─────────────┴───────┘
(2 rows)

Use --format ascii when box-drawing characters are not desired:

lynxdb query 'level=error | stats count by source' --format ascii

Use --format markdown for README or issue comments:

lynxdb query 'level=error | stats count by source' --format markdown

vertical

lynxdb query 'level=error | head 1' --format vertical
  record 1
_time 2026-01-15T00:00:00Z
source nginx
level error
message upstream timeout

The query suffix \G is equivalent to --format vertical when --format is still auto:

lynxdb query 'level=error | head 1 \G'

csv

lynxdb query 'level=error | stats count by source' --format csv
source,count
nginx,340
api-gateway,120

tsv

lynxdb query 'level=error | stats count by source' --format tsv
source	count
nginx 340
api-gateway 120

raw

lynxdb query '_source=nginx | head 3' --format raw
192.168.1.1 - - [14/Feb/2026:14:23:01 +0000] "GET /api HTTP/1.1" 200 1234
192.168.1.1 - - [14/Feb/2026:14:23:02 +0000] "POST /login HTTP/1.1" 302 0
192.168.1.1 - - [14/Feb/2026:14:23:03 +0000] "GET /dashboard HTTP/1.1" 200 5678

Disabling Colors

Colors are enabled by default when output goes to a TTY. Disable them with:

# Flag
lynxdb query 'level=error | stats count' --no-color

# Environment variable (any non-empty value)
NO_COLOR=1 lynxdb query 'level=error | stats count'

Human Table Controls

These global flags apply to table, box, ascii, markdown, vertical, line, G, and TTY auto output:

FlagDescription
--compactReduce table spacing
`--theme autodark
--max-rows <n>Show at most n rows in human output
--max-width <n>Wrap tables to n columns (0 = terminal width)
--null-value <text>Placeholder for null or empty values

Piping and Scripting

When stdout is not a terminal, --format auto produces clean JSON suitable for piping:

# Pipe to jq
lynxdb query 'FROM main | stats count by host' | jq '.host'

# Export to file
lynxdb query 'FROM main | where level="ERROR"' --since 24h > errors.json

# Export as CSV for spreadsheets
lynxdb query 'FROM main | stats count by host' --format csv > report.csv

# Chain with other tools
lynxdb query '| stats count by status' --format csv | sort -t, -k2 -rn

Metadata to stderr

Stats and summary lines are written to stderr so they do not pollute piped output:

# Only JSON goes to the file; stats go to the terminal
lynxdb query --file access.log '| stats count' > result.json
# stderr shows: Scanned 50,000 events | 1 results | 89ms

See Also