npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@insidiousfiddler/bookmarks2data

v0.1.1

Published

A Node.js package to convert browser-exported bookmarks into various formats

Downloads

8

Readme

Bookmarks2Data

Bookmarks2Data is a Node.js package that allows you to easily convert browser-exported bookmarks into various formats such as lists, JSON, and CSV. With Bookmarks2Data, you can parse bookmark files in different formats and seamlessly convert them to your desired output format.

Installation

To install Bookmarks2Data, you need to have Node.js installed on your system. Then, follow these steps:

  1. Open your terminal or command prompt.
  2. Navigate to your project directory.
  3. Run the following command to install the package:
npm install bookmarks2data

Usage

Using Bookmarks2Data in your Node.js project is straightforward. Here's an example of how to convert a browser-exported bookmark file to JSON:

const { BookmarkParser, BookmarkConverter } = require("bookmarks2data");

// Path to your bookmark file
const bookmarkFilePath = "/path/to/bookmarks.html";

// Parse the bookmark file
const parser = new BookmarkParser();
const parsedBookmarks = parser.parseHTML(bookmarkFilePath);

// Convert parsed bookmarks to JSON
const converter = new BookmarkConverter();
const jsonBookmarks = converter.toJSON(parsedBookmarks);

// Print the JSON bookmarks
console.log(jsonBookmarks);

In the above code snippet, we first import the BookmarkParser and BookmarkConverter classes from the bookmarks2data package. Then, we specify the path to the bookmark file we want to convert. Next, we use the BookmarkParser class to parse the HTML bookmark file, and the resulting parsed bookmarks are passed to the BookmarkConverter class to convert them to JSON format. Finally, we print the JSON-formatted bookmarks.

Configuration Options

Bookmarks2Data also provides configuration options to customize the conversion process. Here's an example of how to set the output file name:

const { Config } = require("bookmarks2data");

// Set the output file name
const config = new Config();
config.setOutputFileName("my-bookmarks.json");

In the above code snippet, we import the Config class from the bookmarks2data package. Then, we create a new instance of the Config class and use the setOutputFileName() method to set the desired output file name to 'my-bookmarks.json'.

Error Handling

Bookmarks2Data includes an ErrorHandler class to handle any errors that may occur during the parsing or conversion process. If an error occurs, the package provides meaningful error messages. Here's an example of how to handle parsing errors:

const { BookmarkParser, ErrorHandler } = require("bookmarks2data");

// Path to your bookmark file
const bookmarkFilePath = "/path/to/bookmarks.html";

// Parse the bookmark file
const parser = new BookmarkParser();
const errorHandler = new ErrorHandler();

try {
  const parsedBookmarks = parser.parseHTML(bookmarkFilePath);
  // Continue with further processing
} catch (error) {
  errorHandler.handleParseError(error);
}

In the above code snippet, we import the BookmarkParser and ErrorHandler classes from the bookmarks2data package. We create a new instance of the BookmarkParser class and the ErrorHandler class. Inside a try-catch block, we attempt to parse the bookmark file using the parseHTML() method. If an error occurs, it will be caught, and the handleParseError() method of the ErrorHandler class will handle the error.

Testing

Bookmarks2Data includes comprehensive unit tests to ensure its functionality and reliability. To run the tests, follow these steps:

  1. Ensure that you have installed the package dependencies by running npm install in the root directory of the package.
  2. Open your terminal or command prompt.
  3. Navigate to the root directory of the package.
  4. Run the following command to execute the tests:
npm test

The tests will run, and you will see the results in the console.

Conclusion

Bookmarks2Data simplifies the process of converting browser-exported bookmarks into different formats such as lists, JSON, and CSV. With its intuitive API and configuration options, you can seamlessly integrate it into your Node.js projects.