Convert HTML/XML Markup Into JSON – markup2json

Category: Javascript | October 4, 2023
Views Total:40 views
Official Page:Go to website
Last Update:October 4, 2023


Convert HTML/XML Markup Into JSON – markup2json


markup2json is a compact JavaScript library for parsing HTML and XML strings into JSON objects. Developers can then transform, filter or modify the data before working with it in their applications.

More Use Cases:

  • Parsing API responses containing HTML data into JSON for further processing.
  • Converting HTML templates into JSON for dynamic content generation. Developers can modify the JSON and then reconstruct the HTML.
  • Extracting data from HTML documents. The JSON representation makes it easy to locate specific elements and their attributes.
  • Simplifying HTML data for storage or transport. The JSON format is more compact and lightweight than HTML.

How to use it:

1. Install and import the markup2json.

# Yarn
$ yarn add markup2json
$ npm i markup2json
import markup2json from "markup2json";

2. Convert HTML or XML strings to JSON as follows:

const markup = "HTML/XML Markup Here";
const json = markup2json(markup);


v1.0.5 (10/04/2023)

  • chore: updates dependencies

You Might Be Interested In:

Leave a Reply