format
The .format
command sets the output format for query results in rsql. This allows you to tailor the display for
readability, data export, or integration with other tools. The default format is psql
, but many formats are available
for different use cases.
Usage
.format [format]
Available Formats
Format | Description |
---|---|
ascii | ASCII characters to draw a table |
csv | Comma Separated Values (CSV) |
expanded | PostgreSQL Expanded Format |
html | HyperText Markup Language (HTML) |
json | JavaScript Object Notation (JSON) |
jsonl | JSON Lines (JSONL) |
markdown | Markdown |
plain | Column based layout |
psql | PostgreSQL Standard Format |
sqlite | SQLite formatted table |
tsv | Tab Separated Values (TSV) |
unicode | Unicode characters to draw a table |
xml | Extensible Markup Language (XML) |
yaml | YAML Ain’t Markup Language (YAML) |
When to use
- Use
unicode
,ascii
, orpsql
for interactive exploration. - Use
csv
,tsv
,json
,jsonl
,xml
, oryaml
for exporting data or integrating with other tools. - Use
markdown
orhtml
for documentation or reporting. - Use
expanded
for wide tables or when you want each row displayed vertically.
Examples
Show the current format mode:
.format
Set the format mode to ascii
:
.format ascii
Set the format mode to json
for machine-readable output:
.format json
Troubleshooting
- If output looks garbled in your terminal, try switching to
ascii
orplain
. - For large exports, prefer
csv
,tsv
, orjsonl
for best performance.
Related
- See the
format
option in rsql.toml configuration. - For header/footer control, see header and footer.