A npm package for testing files or url's again the wc3 validator
JavaScript HTML
Switch branches/tags
Nothing to show
Latest commit 557e62b Jun 7, 2017 @thomasdavis committed on GitHub Don't need proxy by default in example
Failed to load latest commit information.
bin add a binary Sep 13, 2013
example Revert "Revert "Update dependencies"" Jun 7, 2017
lib Revert "Revert "Update dependencies"" Jun 7, 2017
.gitignore fixed gitignore Jul 26, 2012
LICENSE added license Jul 26, 2012
README.md Don't need proxy by default in example Jun 7, 2017
package.json Updated 0.4.0 now with breaking api changes because the response retu… Jun 7, 2017


Build Status Dependencies


A node.js library for testing files or url's against the w3c html validator.


npm install w3cjs


var w3cjs = require('w3cjs');

var results = w3cjs.validate({
	file: 'demo.html', // file can either be a local file or a remote file
	//file: 'http://html5boilerplate.com/',
	//input: '<html>...</html>',
	//input: myBuffer,
	output: 'json', // Defaults to 'json', other option includes html
	//proxy: 'http://proxy:8080', // Default to null
	callback: function (err, res) {
		// depending on the output type, res will either be a json object or a html string

Example async testing with Mocha

var w3cjs = require('w3cjs');
describe('html validation', function(){
	it('index page should have no html errors', function(done){
			file: 'index.html',
			callback: function (error, res) {
				console.log(error || res);
				if (res && res.messages.length > 0 ) {
					throw {error: 'html errors have been found', results: res};

Older versions < 0.2.0

w3c has changed their validator API to not include some old options. It will eventually be fully deprecated and everyone is advised to update to 0.3.0 of this module.

doctype: 'HTML5', // Defaults false for autodetect
charset: 'utf-8', // Defaults false for autodetect