vnu is an HTML validation checker. It’s extremely easy to use and integrates well with all your other command-line tools. I installed it with
brew install vnu – it’s also available through
I like to use it in conjunction with cURL, so I can quickly check the validation status of whatever I’m working on:
I prefer the JSON output format, because I can pipe it into
jq as follows:
If your HTML is returned from a JSON endpoint, use another
jq call to extract it from the JSON:
vnu expects full HTML pages, and as such will complain if it’s asked to validate HTML fragments. If you’re validating HTML fragments like in the above examples, you’ll probably see messages like
Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>” or
Element “head” is missing a required instance of child element “title”. Don’t worry if this happens – these are only problems if you’re trying to validate a full page.
Combined with your other tools,
vnu will help you fix your HTML quickly and efficiently. Enjoy!