Skip to content
AnswerWell geo Documentation

Research · 6 min read · Answerwell

Extension Bookmarks API: Tree Nodes, CRUD, and Search

How browser extensions use the bookmarks API to read and change bookmark trees, permissions, limits, and related APIs.

This page summarises Chrome extension documentation on the chrome.bookmarks and browser.bookmarks APIs. Extensions use these APIs to create, organise, and manipulate the user’s bookmark tree from a Manifest V3 or Manifest V2 extension. Bookmark data is separate from browsing history and the reading list; this page focuses on bookmarks unless noted.

bookmarks permission: when an extension may touch bookmarks

Section titled “bookmarks permission: when an extension may touch bookmarks”

Extensions need the bookmarks permission in the manifest before calling bookmark methods or using bookmark-related declarative rules.

Clicking the star adds a bookmark

— Chrome, chrome.bookmarks

The same permission is required for PageStateMatcher.isBookmarked in declarative content:

The PageStateMatcher.isBookmarked condition allows matching of the bookmarked state of the current URL in the user’s profile. To make use of this condition the “bookmarks” permission must be declared in the extension manifest.

— Chrome, browser.declarativeContent

Without that permission, the browser does not expose bookmark read/write APIs to the extension.

Section titled “bookmark tree: how folders and links are organised”

Bookmarks live in a tree: each node is either a bookmark (has a URL) or a folder (sometimes called a group).

Use the chrome.bookmarks API to create, organize, and otherwise manipulate bookmarks. Also see Override Pages, which you can use to create a custom Bookmark Manager page.

— Chrome, chrome.bookmarks

Bookmarks are organized in a tree, where each node in the tree is either a bookmark or a folder (sometimes called a group). Each node in the tree is represented by a bookmarks.BookmarkTreeNode object.

— Chrome, browser.bookmarks

Every API call that creates or moves nodes uses BookmarkTreeNode fields such as parentId, index, title, and url. Child order within a parent is significant: index is the 0-based position under that parent.

BookmarkTreeNode: fields extensions rely on

Section titled “BookmarkTreeNode: fields extensions rely on”
Property Role
id Unique string within the profile; stable across restarts
parentId Parent folder; omitted on the root
index Position among siblings
title Label shown in the UI
url Target for bookmarks; omitted for folders
children Ordered child nodes when present
dateAdded, dateGroupModified, dateLastUsed Timestamps (ms since epoch); dateLastUsed not set on folders
folderType Browser-owned folder kinds (Chrome 134+)
syncing Whether the node syncs via the built-in account provider
unmodifiable e.g. "managed" for admin/custodian-controlled nodes

A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder.

— Chrome, BookmarkTreeNode

New items default to the Other Bookmarks folder when parentId is omitted in CreateDetails.

folderType: special folders extensions cannot delete

Section titled “folderType: special folders extensions cannot delete”

The folderType enum marks browser-defined folders:

Value Meaning
bookmarks-bar Contents shown in the bookmarks bar
other Full bookmark list on all platforms
mobile Bookmarks for mobile, still modifiable by extensions
managed Top-level folder when an administrator configured bookmarks

You cannot use this API to add or remove entries in the root folder. You also cannot rename, move, or remove the special “Bookmarks Bar” and “Other Bookmarks” folders.

— Chrome, browser.bookmarks

If folderType is set, the folder was added by the browser and cannot be removed via the extensions API. Children may still be changeable unless unmodifiable blocks it. There may be zero, one, or multiple nodes per folder type.

Section titled “bookmarks.create and bookmarks.update: add links and folders”

create() adds a bookmark or folder under a given parentId. If url is null or missing, the new node is a folder.

Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder.

— Chrome, bookmarks.create()

update() changes only the fields you pass; today only title and url are supported.

Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged. Note: Currently, only ‘title’ and ‘url’ are supported.

— Chrome, bookmarks.update()

Example pattern from the docs: create a folder on the bar, then add a bookmark with a URL:

browser.bookmarks.create(
{ parentId: bookmarkBar.id, title: 'Extension bookmarks' },
function (newFolder) {
console.log('added folder: ' + newFolder.title);
}
);
browser.bookmarks.create({
parentId: extensionsFolderId,
title: 'Extensions doc',
url: 'https://developer.chrome.com/docs/extensions',
});

On Manifest V3, methods return Promises (Chrome 90+); Manifest V2 also supports optional callbacks.

bookmarks.getTree and bookmarks.search: read and find nodes

Section titled “bookmarks.getTree and bookmarks.search: read and find nodes”

Read the hierarchy with getTree(), a subtree with getSubTree(id), direct children with getChildren(id), or specific nodes with get(idOrIdList). Recently added items use getRecent(numberOfItems).

search() accepts a string or an object. Strings match words and quoted phrases against titles and URLs. Object queries require all specified properties to match (query, title, url); title and url match verbatim. Folders have no url.

Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties.

— Chrome, bookmarks.search()

bookmarks.move, remove, and removeTree: reorganise and delete

Section titled “bookmarks.move, remove, and removeTree: reorganise and delete”

move(id, destination) changes parentId and optional index. remove(id) deletes a bookmark or an empty folder. removeTree(id) deletes a folder and all descendants recursively.

Attempting to remove special bar/other folders or non-empty folders without removeTree conflicts with the tree rules above.

Older docs listed sustained and hourly write caps. Chrome states those limits no longer apply:

Bookmark write operations are no longer limited by Chrome.

— Chrome, MAX SUSTAINED WRITE OPERATIONS PER MINUTE

The same applies to MAX WRITE OPERATIONS PER HOUR. Extensions should still avoid tight loops that hammer the bookmark service, but there is no documented per-minute or per-hour cap.

bookmarks vs history, reading list, and isBookmarked

Section titled “bookmarks vs history, reading list, and isBookmarked”
API Purpose
browser.bookmarks Full bookmark tree CRUD and search
browser.readingList Reading list entries via readingList.query()
browser.history Visit history via history.search()
declarativeContent isBookmarked Match whether the current URL is bookmarked (needs bookmarks permission)

Use the browser.bookmarks API and the browser.readingList API to create, organize, and otherwise manipulate these lists.

— Chrome, Extensions / Develop

History search returns last visit times for matching pages; it does not replace bookmark search when you need title/url bookmark data.

  • Calling bookmark APIs without the bookmarks permission.
  • Assuming remove() clears a folder that still has children (use removeTree()).
  • Trying to rename, move, or delete Bookmarks Bar / Other Bookmarks or root entries.
  • Using update() for properties other than title and url.
  • Treating syncing === false as “not synced anywhere” (third-party sync may still apply).
  • Confusing bookmark search() with history.search() or readingList.query().
  1. Add "bookmarks" to permissions in manifest.json, load the unpacked extension, and confirm bookmark methods run without permission errors (see MV3 bookmarks).

  2. In the extension service worker or background page, call chrome.bookmarks.getTree() and verify the returned BookmarkTreeNode IDs match what you see in the built-in bookmark manager.

  3. Create a test folder and bookmark with create(), then locate them with search({ title: '...' }) or getChildren(parentId).

  4. Confirm remove() fails or leaves structure intact for non-empty folders, and that removeTree() removes nested items as expected.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about so it can be corrected.