Salesforce is a big ocean, and every day we learn something. While exploring SOQL in VS Code, I found an ability to export query output to CSV. Isn’t it a fantastic way to export query output in CSV directly from Visual Studio Code and share it with the Sales team or anyone if needed? That too without installing an additional plugin.
Let’s get started – but take a minute pause here – how about if you first learn how to run and save a query in Visual Studio code.
Please do so now if you haven’t gotten a chance to read my last blog on, Execute & Save Query in VScode. It will help to save queries in visual studio code to reuse them.
Let’s start with a real-time use case.
Use Case
In response to my previous blog, How to Execute a Query in Visual Studio Code, I received a message from Chris; how can we export SOQL query output to a CSV file from VS code. A lot of scrolling is required to analyze the result.
Prerequisite
Connect Visual Studio Code to the org in which you want to execute the query and export output.
Use this link to set up and connect your org with Visual Studio Code.
Solution
- Click on the Explorer icon.
- Go to Project name | Scripts.
- Click on soql | Filename ( you want to execute and save output i.e. Account.soql ).
- Click on Switch Between SOQL Builder and Text Editor.

- Click on the Run Query button.




- Click on the .csv file button to export the output and save it.




You are Done!!!
I would love to hear about your experience with Visual Studio Code to execute SOQL and export data to the .csv file. How do you use it?