Is there a DML or other way to delete all records from the developer console? For example, we have 100K Leads in our testing environment and we would like to delete all of them in one operation.

Is that possible?

By the way, I saw there is a mass delete option, although it only lets you delete a few hundreds records at a time.... (using Setup-> Administration Setup->Data Management -> Mass Delete Records.)

7 Answers 7


You can delete records from the developer console with the line

delete [SELECT Id FROM MyObject];

However, this isn't going to delete 100k records successfully due to governor limits. You're going to need to use dataloader to export the 100k records, then use the export to delete the records.

Edit: Better than that, you can use LIMIT to select a subset, and then rerun the command after each execution

delete [SELECT Id FROM MyObject LIMIT 10000];
  • 10
    Is this answer still valid? When I try it I got error "Invalid query: The query has to start with 'FIND' or 'SELECT'"
    – Zorji
    Commented Oct 10, 2016 at 0:18
  • This answer is still valid, at least for standard objects like 'Contact'. I was able to delete records with a vengeance. (This is far superior to the troublesome 'mass delete' interface that deletes 250 at a time, assuming there no hidden errors that don't allow records to be deleted..!
    – ryanm
    Commented Feb 7, 2017 at 23:48
  • I am not able to use delete for deleting Contacts in developer console. I tried the SOQL and it did not work. Got the error mentioned by @Zorji Commented Apr 25, 2017 at 3:42
  • 2
    @Zorji , stack - That is a line of Apex code, not a SOQL query. CTRL-E for a window to run it. And: Caveat deletor :) .
    – ElHombre55
    Commented Sep 16, 2021 at 15:52
  • Execute as anonymous apex. Commented Jan 31 at 17:54

One way to delete using Developer Console is to first execute your query

SELECT Id from My_Custom_Object__c

Then highlight all the result rows and click on the Delete Row button at the bottom.

enter image description here

  • @ Bhavana thanks, simple and efficient (ok) Commented Jun 24, 2020 at 8:00
  • 3
    The question asks how to delete 100k records. This doesn't seem efficient for that.
    – rykener
    Commented Aug 11, 2020 at 22:19

Using Apex Data Loader to delete records:

First, you have to export all the records (the ID will be sufficient) to a csv file. Then you can delete all the records based on that csv file. When you perform the delete make sure you map the ID column of the csv file to the Id column of the object.

This way took me a few minutes to delete 120K records (Lead).


I add something to your answers. There are two ways to solve this problem, in addition to the console. I think that the console could be very useful, but maybe in production one wants to have an higher "control" on the data. In that case there are two ways.

1) Use the Workbench:

  • connect to the product (if you have a developer licence check this option) or to the test org;
  • Tab Query - click on SOQL query;
  • write a query to identify the records to delete: SELECT Id FROM Account WHERE revenue > 1234 ;
  • check the Bulk CSV radio button;
  • click on the "Query" button, wait the processing of the records, and then download it (it will be saved in .csv format);

This file can now be used to delete those records from the org:

  • Tab Data - click on Delete;
  • Eventually enter again in your org;
  • choose the From File radio button;
  • Map the field;
  • Delete all!

1) Use the Data Loader:

  • download it from

Setup - Data Management - Data Loader

  • enter in the Data Loader using the password of your org + the security token;
  • check in the Settings tab if you are accessing in the right environment (test.salesforce or login.salesforce);
  • following the instructions suggested in the previous answer.
  • If you use the Workbench option, download the resulting file by clicking the icon to the left of the Batch Id - not the Batch Id itself! Hope this saves others :)
    – burntsugar
    Commented Aug 7, 2021 at 8:34

To delete more than 50,000 records, you can use the DataLoader program. Follow these steps...

-Open the data loader and choose "export". Navigate to your object and select it, then choose the 'id' field. You only need the 'id' for each record in order to delete it. Export this to a csv file.

-Open the data loader again and choose "delete". Navigate to your object and select it. Then import the csv file you have just saved containing the IDs for all your records. Import that and map the 'id' field to that of your object.


2 ways,

  • Either batch apex with acceptable batch size and business logic.
  • Apex Data Loader (as explained in above answers)
    • Using bulk api you can really speed up the deletion.
    • Normal apex loader deletion can also do the trick with specified batch size.

I have made an open source GitHub project for deleting multiple records in batches. you can go through the project and embrace the functionalities as per your requirements. Github Repo : https://github.com/vipul-goyal/Salesforce-Batch-To-Delete-Records

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .