bookmarks.getTree() returns an array containing the root of the bookmarks tree as a bookmarks.BookmarkTreeNode object.

You can access the entire tree recursively using its children property and the children property of its descendants, if they are themselves folders.

This is an asynchronous function that returns a Promise.


var gettingTree = browser.bookmarks.getTree()



Return value

A Promise that will be fulfilled with an array containing one object, a bookmarks.BookmarkTreeNode object representing the root node.


This example prints out the entire bookmarks tree:

function makeIndent(indentLength) {
  return ".".repeat(indentLength);

function logItems(bookmarkItem, indent) {
  if (bookmarkItem.url) {
    console.log(makeIndent(indent) + bookmarkItem.url);
  } else {
    console.log(makeIndent(indent) + "Folder");
  if (bookmarkItem.children) {
    for (child of bookmarkItem.children) {
      logItems(child, indent);

function logTree(bookmarkItems) {
  logItems(bookmarkItems[0], 0);

function onRejected(error) {
  console.log(`An error: ${error}`);

var gettingTree = browser.bookmarks.getTree();
gettingTree.then(logTree, onRejected);

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxOperaFirefox for Android
getTreeChrome Full support YesEdge Full support 15Firefox Full support 45Opera Full support YesFirefox Android No support No


Full support  
Full support
No support  
No support


This API is based on Chromium's chrome.bookmarks API. This documentation is derived from bookmarks.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

Contributors to this page: mdnwebdocs-bot, irenesmith, wbamberg, jerrykrinock, Makyen, Sheppy
Last updated by: mdnwebdocs-bot,