Socket
Socket
Sign inDemoInstall

parse5

Package Overview
Dependencies
0
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    parse5

WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.js


Version published
Weekly downloads
39M
decreased by-0.36%
Maintainers
1
Install size
370 kB
Created
Weekly downloads
 

Package description

What is parse5?

The parse5 npm package is a fast full-featured specification-compliant HTML parser for Node.js. It allows users to parse HTML documents and manipulate the resulting document tree structure. The package provides a variety of modules for parsing, serializing, and tree adaptation based on the DOM (Document Object Model) interface.

What are parse5's main functionalities?

Parsing HTML

This feature allows you to parse an HTML string into a document tree that can be manipulated or queried.

const parse5 = require('parse5');
const html = '<!DOCTYPE html><html><head></head><body>Hi there!</body></html>';
const document = parse5.parse(html);

Serializing Document

This feature enables you to serialize a document tree back into an HTML string.

const parse5 = require('parse5');
const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
const html = parse5.serialize(document);

Streaming

This feature allows you to use parse5 in a streaming mode, which is useful for processing large HTML documents without loading them entirely into memory.

const parse5 = require('parse5');
const fs = require('fs');
const file = fs.createReadStream('example.html');
const parser = new parse5.SAXParser();
parser.on('text', (text) => {
  console.log(text);
});
file.pipe(parser);

Tree Adapters

This feature allows you to use different tree adapters to interact with the parsed document tree in a way that is compatible with other libraries or your own custom requirements.

const parse5 = require('parse5');
const htmlparser2Adapter = require('parse5-htmlparser2-tree-adapter');
const html = '<!DOCTYPE html><html><head></head><body>Hi there!</body></html>';
const document = parse5.parse(html, { treeAdapter: htmlparser2Adapter });

Other packages similar to parse5

Readme

Source

parse5

WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.js

Build Status NPM Version Downloads Downloads total

parse5 provides nearly everything you may need when dealing with HTML. It's the fastest spec-compliant HTML parser for Node to date. It parses HTML the way the latest version of your browser does. It has proven itself reliable in such projects as jsdom, Angular2, Polymer and many more.


Documentation

Version history

Online playground

Issue tracker

Keywords

FAQs

Last updated on 19 Oct 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc