Build Status Go Reference

markdownfmt is a CLI that reformats Markdown files (like gofmt but for Markdown) and a library that you can use to generate well-formed Markdown files.




go install


go get


usage: markdownfmt [flags] [path ...]
  -d    display diffs instead of rewriting files
        reformat Go source inside fenced code blocks
  -l    list files whose formatting differs from markdownfmt's
  -list-indent-style value
        style for indenting items inside lists ("aligned" or "uniform")
        wrap lines even on soft line breaks
  -u    write underline headings instead of hashes for levels 1 and 2
  -w    write result to (source) file instead of stdout

The markdownfmt CLI supports the following execution modes:

  • stdout: Write reformatted contents of provided files to stdout. This is the default.
  • write (-w): Reformat and rewrite Markdown files in-place.
  • list (-l): List files that would be modified, but don't change them.
  • diff (-d): Display a diff of modifications that would be made to files, but don't change them.


markdownfmt began as a fork of shurcooL/markdownfmt targeting Goldmark instead of Blackfriday. It has since diverged significantly.

  • shurcooL/markdownfmt: The project that this forked from.
  • mdox: Builds upon markdownfmt. Adds support for link validation, command execution, and more.

Editor Plugins


  • mdfmt - Fork of markdownfmt that adds front matter support.
  • tidy-markdown - Project with similar goals, but written in JS and based on a slightly different styleguide.