Documentation
How to Export Contact Form 7 Submissions as CSV
Learn how to export all Contact Form 7 (CF7) submission history to CSV. We cover the trick for UTF-8 BOM output so Excel doesn't show garbled characters, plus a comparison between exporting through settings alone (no code) and building your own implementation.
If you want to tally and analyze your inquiries, it’s much faster to export your Contact Form 7 (CF7) submission history as CSV and work with it in Excel. The problem is that CF7 doesn’t include a CSV export feature out of the box, and writing your own export code tends to run into garbled-character issues in Excel.
This article covers a no-code way to export your data, along with tips for building your own implementation.
Why you need CSV export
Tallying monthly inquiry counts, breaking down submissions by traffic source, sharing a list with your sales team — for all of these, the fastest approach is exporting to CSV and loading it into Excel or a spreadsheet. Rather than reviewing entries one by one in the admin screen, exporting everything at once lets you sort and pivot the data, which makes analysis much easier.
Prerequisite: submission data must already be saved
CSV export assumes that your submissions are already being saved to the database. If you haven’t set this up yet, first complete How to save submissions to the database.
Method 1: Do it entirely from the settings screen (no code, recommended)
Without touching functions.php, you can export your submission data to CSV using only the WordPress admin screen. With Frontierline Forms, you can complete this in the following steps.
Steps
- Confirm saving is enabled: Make sure your submission data is being saved to the database.
- Specify the export range: In the admin screen, choose the export range, such as form and date period.
- Export the CSV: Run the export and download the CSV.
- Check it in Excel: Confirm there’s no garbling and that each column is split correctly.
The plugin handles adding the UTF-8 BOM and escaping commas and line breaks, so the file opens correctly in Excel right away.
Method 2: Build your own CSV export (for advanced users)
If you’re writing your own code, you export the results of a SELECT against your storage table as CSV. The key to avoiding garbled characters in Excel is adding a UTF-8 BOM at the start of the file.
// Example: fetch from the storage table and output as CSV
$rows = $wpdb->get_results("SELECT created_at, name, email, message FROM {$wpdb->prefix}cf7_entries", ARRAY_A);
header('Content-Type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename="entries.csv"');
echo "\xEF\xBB\xBF"; // UTF-8 BOM (prevents garbled characters in Excel)
$out = fopen('php://output', 'w');
fputcsv($out, ['Submitted At', 'Name', 'Email', 'Message']);
foreach ($rows as $r) {
fputcsv($out, $r);
}
fclose($out);
Common pitfalls with a manual implementation
- Garbled characters in Excel without a BOM: If you don’t output
\xEF\xBB\xBFat the start of the file, Japanese text will get corrupted in Excel. - Escaping line breaks and commas: If the message body contains line breaks or commas, columns can shift out of alignment.
fputcsvhandles most of this, but depending on your output path, you may need extra handling. - Memory exhaustion with large datasets: Loading every record into an array at once gets heavy. With a large number of records, you’ll need chunked output or streaming.
- Export trigger and permissions: You’ll need to build your own access flow and permission checks for where in the admin screen the export happens and who is allowed to run it.
For a one-off export, building it yourself is doable, but rather than handling garbling, escaping, and permissions every time, Method 1 — exporting everything with a single click — is the more reliable option.
Summary
Since CF7 doesn’t include CSV export by default, you either need to write your own export from the storage table or use a plugin that supports it. A custom implementation is prone to pitfalls around UTF-8 BOM and escaping. If you want to export all records cleanly, without garbling, using only the settings screen, a plugin built for this is the faster path.
If you want CSV export of all records, along with saving submission logs to the database, Slack/Chatwork/spreadsheet notifications, and multi-step forms — all set up purely through configuration — consider adopting Frontierline Forms.
Frontierline Forms
This setup takes just a checkbox in the admin.
Add alerts, submission logging, CSV export and multi-step forms without writing code — all from the settings screen. The 5-site / unlimited license lets agencies cover form maintenance across many client projects at once. Your license key is issued instantly on payment.