Tools to validate markdown documents as following the CommonMark specification


I’ve picked up the habit of writing all of my notes in Markdown as of late, but I’ve noticed that different text editors seem to format my notes differently. This is fine, but I would like a tool (preferably a command line tool, but an editor plugin is fine too) which can take a file and let me know if it’s properly formatted CommonMark markdown.

I’ve searched for this, but all the results I’ve found have been more like test suites for people writing markdown renderers to ensure that their code can handle the full range of the markdown specification. What I’m looking for is rather the opposite – I want something that interprets the CommonMark spec strictly and then lets me know if what I’m writing passes a stringent interpretation of the specification.

Does such a tool exist?


Such a tool cannot exist because every file is a valid Commonmark file. However, there could be a tool that highlights different outputs for the same input, but it would need to ship with or have access to different parsers. Babelmark 2 and 3 are such tools working online. Their purpose is different, not being intended for authors but developers.

You could run Pandoc, for instance, to convert a markdown file into a specific flavor, e.g. --from markdown_strict --to commonmark, and then diff input and output, or you could run it twice with different options and compare the outputs.


Quoting Section 2.1 of the spec:
“Any sequence of characters is a valid CommonMark document.”

So a tool to tell you if you have a valid CommonMark
document would be trivial. Of course, the meaning of
the document might not be what you expect, but to test
for this you’d need a tool that takes as input both
the document and its intended interpretation.

Rohit Patnaik writes: