A simple PHP class for creating custom Firefox bookmark JSON files.
<?php
require('FirefoxBookmarks.php');
$fb = new \evan_klein\firefox_bookmarks\FirefoxBookmarks();
// Bookmarks toolbar
$fb->addToolbarBookmark('Google', 'https://www.google.com/')
->addToolbarBookmark('YouTube', 'https://www.youtube.com/')
->addToolbarSpacer()
->addToolbarFolder(
'Social Media',
[
$fb->bookmark('Reddit', 'https://www.reddit.com/'),
$fb->bookmark('X', 'https://x.com/'),
$fb->folder(
'Meta',
[
$fb->bookmark('Facebook', 'https://www.facebook.com/'),
$fb->bookmark('Instagram', 'https://www.instagram.com/')
]
)
]
);
// Bookmarks menu
$fb->addMenuBookmark('Amazon', 'https://www.amazon.com/')
->addMenuBookmark('Wikipedia', 'https://www.wikipedia.org/')
->addMenuSpacer()
->addMenuFolder(
'News',
[
$fb->bookmark('Google News', 'https://news.google.com/'),
$fb->bookmark('Yahoo', 'https://www.yahoo.com/'),
$fb->bookmark('NPR', 'https://www.npr.org/')
]
);
// Custom search shortcuts
$fb->addMenuBookmark('Reddit Search', 'https://www.google.com/search?q=%s+site%3Areddit.com', 'r')
->addMenuBookmark('Amazon Search', 'https://www.amazon.com/s?k=%s', 'amz');
echo $fb->output();
?>
The code above generates the JSON below:
{
"guid": "root________",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"root": "placesRoot",
"children": [
{
"guid": "menu________",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "menu",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"root": "bookmarksMenuFolder",
"children": [
{
"guid": "sDh2sdIWYhQc",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Amazon",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.amazon.com\/"
},
{
"guid": "QEXXVMyCuELN",
"index": 1,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Wikipedia",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.wikipedia.org\/"
},
{
"guid": "TRGFW690AMU8",
"index": 2,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "",
"typeCode": 3,
"type": "text\/x-moz-place-separator"
},
{
"guid": "pM4cOn8YRQyn",
"index": 3,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "News",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"children": [
{
"guid": "ZF8RT2WS61tQ",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Google News",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/news.google.com\/"
},
{
"guid": "iQieops5iLgO",
"index": 1,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Yahoo",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.yahoo.com\/"
},
{
"guid": "fyX7IVPBXqiW",
"index": 2,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "NPR",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.npr.org\/"
}
]
},
{
"guid": "vJBjNhdTwqV6",
"index": 4,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Reddit Search",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.google.com\/search?q=%s+site%3Areddit.com",
"keyword": "r"
},
{
"guid": "PWlSFDlagLku",
"index": 5,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Amazon Search",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.amazon.com\/s?k=%s",
"keyword": "amz"
}
]
},
{
"guid": "toolbar_____",
"index": 1,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "toolbar",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"root": "toolbarFolder",
"children": [
{
"guid": "YBmMiHYhBdYL",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Google",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.google.com\/"
},
{
"guid": "5YkKv6Fo3ki1",
"index": 1,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "YouTube",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.youtube.com\/"
},
{
"guid": "PwDN8zKmXlSj",
"index": 2,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "",
"typeCode": 3,
"type": "text\/x-moz-place-separator"
},
{
"guid": "ohAKk5O5DWea",
"index": 3,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Social Media",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"children": [
{
"guid": "8JGLR11Lla6m",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Reddit",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.reddit.com\/"
},
{
"guid": "jrnCpOHXmzVS",
"index": 1,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "X",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/x.com\/"
},
{
"guid": "xeG3ccXtQc3e",
"index": 2,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Meta",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"children": [
{
"guid": "EGFNELHXacnX",
"index": 0,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Facebook",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.facebook.com\/"
},
{
"guid": "KBMKAsKiFJtX",
"index": 1,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "Instagram",
"typeCode": 1,
"type": "text\/x-moz-place",
"uri": "https:\/\/www.instagram.com\/"
}
]
}
]
}
]
},
{
"guid": "unfiled_____",
"index": 2,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "unfiled",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"root": "unfiledBookmarksFolder"
},
{
"guid": "mobile______",
"index": 3,
"dateAdded": 1718557625000000,
"lastModified": 1718557625000000,
"title": "mobile",
"typeCode": 2,
"type": "text\/x-moz-place-container",
"root": "mobileFolder"
}
]
}