open-form responses export
Export a form's responses from the workspace's database (SQLite or Postgres) as CSV, Excel or JSON, to stdout or a file, oldest first.
npx open-form responses export meetup # CSV to stdout
npx open-form responses export meetup -o responses.xlsx # Excel file
npx open-form responses export meetup --format json > responses.jsonReads one form's responses from the workspace's database (Postgres at
OPEN_FORM_DATABASE_URL or storage.url, else SQLite at OPEN_FORM_DB,
storage.path or .open-form/open-form.db), oldest first, and writes them to
stdout or a file — the same file Studio's export gives you. It exits with an
error if there's no SQLite database yet.
For CSV and Excel it also loads the form the way the server does (like
open-form check), for its current labels, languages and
time zone. If the form doesn't load, it warns and exports with the columns
stored alongside the responses; a form whose folder is gone exports that way
too, without the warning. Either way the file has no Language column, and
Excel and CSV use the project's time zone, not one set in Studio.
Flags
| Flag | Default | Description |
|---|---|---|
--format <format> | from -o, else csv | csv, xlsx or json. |
-o, --out <file> | stdout | Write to a file instead of stdout. |
Without --format, the file extension decides: .json gives JSON, .xlsx
gives Excel, anything else — or no -o — gives CSV.
Formats
- CSV and Excel have one column per field, headed by its label. Columns
cover every version of the form, so a field you've since removed keeps its
column for older responses. Translated forms get a Language column after
Submitted at, naming each language. Both show Submitted at in the
form's time zone: the one set in Studio's Settings, else the form's
timeZone, else the project's. Checkboxes read Yes or No. Both need the form to load; see above. - JSON is an array of submissions, each with
id,number,submittedAt,locale(when one was recorded) anddata, the raw answers keyed by fieldname.
Excel files are binary, so xlsx won't print to a terminal. Pass
-o responses.xlsx, or redirect stdout to a file.
Answers come from strangers. Printed to a terminal, control characters in them
show as � so they can't send escape sequences to it. Files written with -o
are readable by you only, and the .gitignore that open-form init writes
keeps responses*.csv, .xlsx and .json at the workspace root out of git.
CSV cells that contain a comma, semicolon, tab, quote or line break are quoted,
and cells that would start a spreadsheet formula get a leading '. A + followed
only by digits, like an international phone number (+886912345678), can't run
anything and is written as stored; spreadsheets may show it as a number, so
export .xlsx to keep it as text there.
When writing to a file, the summary line goes to stderr, so stdout stays clean for pipes.
Studio's Responses tab exports the same three formats. See Responses.