Using SharePoint JavaScript Client Object Model to Get Term Store

In SharePoint 2013 it is very easy to use and get SharePoint taxonomy by using JavaScript Client Object Model.

So, now let us see how to get Term Store Using SharePoint JavaScript Client Object Model step by step.

1. Add a Page in your site and add a Content Editor Web Part in your page.
2. Add JQuery min file by adding reference file in your Site Assets or Add google api reference in Content Editor Web Part.
<script type="text/JavaScript"
3. Load "SP.js" file in your Content Editor Web Part (in SharePoint 2013 it is registered by default).
<script type="text/JavaScript" src="/_layouts/SP.js"></script>

Using SharePoint JavaScript Client Object Model to Get Term Store

    LoadAndExecuteSodFunction('sp.js', function () {
        LoadAndExecuteSodFunction('SP.Taxonomy.js', function () {
             var Terms = loadTerms();
Click to know How to Use JavaScript Client Object Model

function loadTerms() {
    var TermSetName = "TermSetName";

    //Current Context
    var context = new SP.ClientContext(_spPageContextInfo.siteServerRelativeUrl);
    //Get current Site from Current Context
    var site = context.get_site();

    //Load Terms by passing Term Name
    var terms = SP.Taxonomy.TaxonomySession.getTaxonomySession(context).getDefaultSiteCollectionTermStore().getSiteCollectionGroup(site, false).get_termSets().getByName(TermSetName, 1033).get_terms();


    context.executeQueryAsync(onQuerySucceeded(sender, args) {
        var enumer = terms.getEnumerator();

        var TermValues = [];

        while (enumer.moveNext()) {
             var term = enumer.get_current();
             var TermValue = {
                            Name: term.get_name(),
                            Desc: term.get_description(),
                            ID: term.get_id().ToSerialized()

                        alert("Adding " + TermValue.Name);
        function onQueryFailed(sender, args) {
              alert('Error: ' + args.get_message() + '\n' + args.get_stackTrace());

    return {
        loadTerms: loadTerms
If you try to access other properties you see an exception message because other properties are not loaded in this context.

Hope this Article is Helpful for you. Keep checking this space.

Sudheer Gangumolu

I'm a Software Analyst / Developer / Blogger, having good experience in working with different flavors & Customization of SharePoint (i.e.,SP O365 / 2013 / 2010 / 2007) and .Net Apps. Currently, working on SharePoint 2013 / SharePoint O365. Guiding people on my technologies.

    Blogger Comment
    Facebook Comment


  1. How to get the page url that is associated with each term?
    And how to get children terms, grandsons terms e so on recursively?

  2. Thanks for share this code.
    I have user above code but I have a error: "_spPageContextInfo is undefined"
    Please cleare me about this error.

  3. How to access children and grand children terms to display in navigation as menu and sub-menus

  4. How to obtain announcement list title,body and date from that particular list and display it in div tag using javascript?? is it possible??

    1. Hi, You can get List Properties and List Items using and bind it to div.