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, orpsqlfor interactive exploration. - Use
csv,tsv,json,jsonl,xml, oryamlfor exporting data or integrating with other tools. - Use
markdownorhtmlfor documentation or reporting. - Use
expandedfor 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
asciiorplain. - For large exports, prefer
csv,tsv, orjsonlfor best performance.
Related
- See the
formatoption in rsql.toml configuration. - For header/footer control, see header and footer.