Small Python Snipet to Export Firefox Bookmarks To Markdown

Firefox allows you to backup your bookmarks to a JSON file. I wanted to quickly export it to markdown rather than the HTML offered by Firefox itself.

import json
bdict = json.load(open('bookmarks-2020-12-29.json', 'r'))
def parse_firefox_bookmark(bdict, header=""):
    if 'children' not in bdict.keys():
            # There are some nodes with no uri and string comparisons slows
            # the program so just ignore the exceptions.
            print('*', '[' + bdict['title'] + ']' + '(' + bdict['uri'] + ')') 
    print(header, bdict['title'])
    for children in bdict['children']:
        parse_firefox_bookmark(children, header+'#')

Sample output.

# Bookmarks Menu
## Mozilla Firefox
* [Help and Tutorials](
* [Customize Firefox](
* [Get Involved](
* [About Us](
* [About Us](
* [Customize Firefox](
* [Help and Tutorials](
* [Get Involved](
* [Help and Tutorials](
## Software
* [The Last Statusline For Vim • kade killary](
* [vimperator cheat sheet](
Have you written a response to this? Let me know the URL