
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
html-validator
Advanced tools
A Node.js module for validating html using validator.w3.org/nu
Requires Node >= 8.15.3 for older versions use v3.13
Supports the following modes from Validator.nu Web Service Interface
$ npm i html-validator
Create an options object.
format This is the formatting of the returned data. It supports json (default), html, xhtml, xml, gnu and text.
validator You can override the default validator as long as it exposes the same REST interface.
url/data The url to the page you want to validate or the data you want validated.
ignore String or array of strings you want the checker to remove in the response
isLocal Set this to true if you want to validate local urls
(async () => {
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
format: 'text'
}
try {
const result = await validator(options)
console.log(result)
} catch (error) {
console.error(error)
}
})()
data The html you want to validate
(async () => {
const validator = require('html-validator')
const { readFileSync } = require('fs')
const options = {
url: 'http://url-to-validate.com',
format: 'text',
data: readFileSync('file-to-validate.html', 'utf8')
}
try {
const result = await validator(options)
console.log(result)
} catch (error) {
console.error(error)
}
})()
validator You can override the default validator as long as it exposes the same REST interface.
(async () => {
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
validator: 'http://html5.validator.nu',
format: 'text'
}
try {
const result = await validator(options)
console.log(result)
} catch (error) {
console.error(error)
}
})()
ignore String or array of strings you want the checker to remove in the response. Requires format = text
(async () => {
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
format: 'text',
ignore: 'Error: Stray end tag “div”.'
}
try {
const result = await validator(options)
console.log(result)
} catch (error) {
console.error(error)
}
})()
headers Object of headers to pass in with the url request
(async () => {
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
format: 'text',
headers: {foo:"bar"}
}
try {
const result = await validator(options)
console.log(result)
} catch (error) {
console.error(error)
}
})()
isLocal Set this to true if you want to validate local urls. Will lookup page and send data to validator
(async () => {
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
format: 'text',
isLocal: true
}
try {
const result = await validator(options)
console.log(result)
} catch (error) {
console.error(error)
}
})()
FAQs
Validate html using validator.w3.org/nu og html-validate
The npm package html-validator receives a total of 14,027 weekly downloads. As such, html-validator popularity was classified as popular.
We found that html-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.