tag: python

Small Python Snipet to Export Firefox Bookmarks To Markdown

29 Dec, 2020 - 1 minutes
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(): try: # There are some nodes with no uri and string comparisons slows # the program so just ignore the exceptions. print('*', '[' + bdict['title'] + ']' + '(' + bdict['uri'] + ')') except: pass return print(header, bdict['title']) for children in bdict['children']: parse_firefox_bookmark(children, header+'#') parse_firefox_bookmark(bdict) Sample output.