function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bernd NawrathBernd Nawrath 

How to delete an apex class

Hello dear community, I was wondering how exactly to delete an apex class because obviously you can't do that in the production area, I already tried deleting it from my sandbox which worked but it didnt have any impact on my actual production area.
Thanks in advance
Shaijan ThomasShaijan Thomas
1.Comment all code inside the class in Sandbox. 
2. Migrate the class to production.
3. use ANT destruction command for the class.
it will work
Shaijan Thomas
You can't delete the apex class directly in production but through eclipse you can delete the apex class and trigger. Follow the below steps to do that in production instances,
  • Create new project in eclipse and download all the source code from production
  • Open the meta-data of the file you want to delete in production and change the status to Delete
  • Click save to server to delete the class in the production
<?xml version="1.0" encoding="UTF-8"?>
     <ApexClass xmlns="">
I strogly recommend this method to try first in the dev or sandbox instance and get comfortable and then do the same step in production.

First, ensure you have backup of the class (Eclipse, BitBucket/GitHub, etc.).

From the Knowledge Article (
- IDE should be installed and working.
- Connect to the Sandbox Instance using the IDE and find the class or trigger that you want to delete.
- Open the matching .xml file change the Status XML tag from "Active" to "Deleted" if you want to remove the trigger or class, or to "Inactive" if you want to disable the trigger.
- Apex class Status can only be changed to "Active" or "Deleted", not "Inactive".
- Save the file.
- Select the two files (Code and XML) using Ctrl-click, then right click on one of them. Select > Deploy to server.
- Provide your credentials for the production org and follow the steps.

Does this help? Let me know if you have trouble in locating the xml part of the file.

Apologies for cross-post @Karan. 
@Anhi - You have provided more information than me, I strongly endrose your answer :)
Thanks Karan :)

@Bernd, more useful discussions -

There are always multiple solutions in ;)

Abhishek Shukla 97Abhishek Shukla 97
Hello All, 

In the developer Edition I tried this : 

1: Open Setup 
2; Pltform Tools>Custom Codes> Apex Classes> Locate the Class
3: Delete 

Although it deleted the class for me but I have seen nobody suggested it yet could you please help me to know is it a recommended step or not??
Abhishek, if you read the question and related replies properly, you will know that it was about deleting the class in a production org, not DE.
Tien Le 488Tien Le 488
Thank you, @Abhishek Shukla 97. Your suggestion help my scenario!!