How can we count number of custom labels available in Apex class in Salesforce? Do we have any query for this ?

4 Answers 4


Metadata API with the following solution.

  1. Login to Workbench.

  2. Go to 'Migration | Retrieve'

  3. Upload package.xml below
  4. Unzip output and count number of labels by <fullname>

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

To do that in Apex, you may get more details in the shared link. By deploying to your org, there's a demo page that does so.

enter image description here enter image description here


  • 1
    Instead of manual counting, you can use this tool to count the <fullname> nodes.
    – Saroj Bera
    Jan 5, 2017 at 9:46
  • Thanks @EugeneO ..but I want to use this count in Apex class. How can I do this?
    – oookkk
    Jan 5, 2017 at 10:23
  • @oookkk, updated answer with my own testing above, you may refer shared the referenced solution.
    – EugeneO
    Jan 5, 2017 at 13:44

You can use Metadata API. Take a look at Andrew Fawcett's Apex Wrapper Salesforce Metadata API.

With the API you can query the CustomLabels metadata type to get the information you are looking for.


Easiest way is probably Workbench>Info>Metadata Types & Components>CustomLabel and check the number


  • but I want to use this count in Apex class. How can I do this?
    – oookkk
    Jan 5, 2017 at 10:23
  • You should start by putting that info in your question. Jan 5, 2017 at 10:27
  • thanks..Is there is any query ?
    – oookkk
    Jan 5, 2017 at 10:33

I don't think its possible for now. You can vote this Idea.

Custom Labels count

You must log in to answer this question.

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