What programs can I use to validate HTML/XML markup?

Basically, I want a local, command-line based, version of W3C HTML validation service (like lint) that I can use for detecting errors.


I would also accept a solution that uses the W3C web service from the command line.

Related Questions:

How can I validate HTML offline?

5 Answers 5


The W3 validator is open source (written in Python I believe) so you can download and run it locally. I can't for the life of me find the download link on w3.org though.


HTML Tidy, developed by Dave Raggett of W3C, can validate & automatically fix errors. It can work from the command-line

  • I like tidy, is it as comprehensive as the W3C tool?
    – cmcginty
    Aug 21, 2010 at 1:51

Total Validator seems to do what you're looking for


The HTML5 validator source code is available through SVN, has dependencies on Java.

  • What do you mean by "the"? That's not an official program, is it? Aug 19, 2010 at 14:07
  • @DisgruntledGoat It's the only one linked to from the WHATWG website: validator.whatwg.org
    – robertc
    Aug 19, 2010 at 14:48

You can now use the new Linux command line tool htmlval for checking HTML and CSS.

Note: I'm the developer.

Testing this HTML (in file example.html):

<html lang="en">
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
<span>span has no end tag

With this command (-l for list format, -S for no SEO messages):

htmlval -lS example.html

Produces this error list:

=== File 1 of 1: example.html ===

Error (line 6, col 11): This document has a <title> element but it does not contain a title when it must. Each page on a site should have its own unique (never duplicated) and well-written title.

Error (line 9, col 2): The <badtag> element is not valid. Is it misspelled?

Error (line 10, col 2): The <span> element must have an end tag (</span>) but the end tag was not found, is misplaced, misspelled, or was not seen due to other errors.

Error (line 11, col 2): The end tag for <span> (started in line 10, column 2) should appear before this </body> end tag or this end tag should be deleted or moved. This is a nesting error.

Comment: "Errors and warnings only" mode enabled. Showing only error and warning messages (with some exceptions).
  • Thanks for the declaration and the development. Your answer would be great if you were to give a summary or screenshot of results. Oct 30, 2022 at 19:00
  • @RohitGupta, thank you. I've added example input and output. I hope this is what you were wanting. Nov 1, 2022 at 4:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.