An opinionated, CommonMark-compliant Markdown formatter and Python library for enforcing consistent style.
Mdformat is an opinionated Markdown formatter that enforces a consistent style in Markdown files. It solves the problem of inconsistent formatting in Markdown documents by providing a tool that automatically formats them according to CommonMark standards. It can be used both as a command-line utility and as a Python library.
Developers and technical writers who work with Markdown files and need to maintain consistent formatting across documentation, READMEs, or other Markdown-based content.
Developers choose Mdformat for its strict CommonMark compliance, pure Python implementation (avoiding Node.js dependencies), and extensible plugin system. It offers a lightweight, reliable alternative to other formatters with fewer bugs and smaller package size.
CommonMark compliant Markdown formatter
Adheres rigorously to the CommonMark specification, reducing formatting bugs and ensuring predictable output compared to tools like Prettier.
Supports parser extensions and code formatter plugins, allowing customization for custom syntax (e.g., tables of contents) and embedded code formatting.
Runs solely on Python without Node.js, making installation straightforward in Python environments and keeping package size small.
Easily integrates as a pre-commit hook for automated formatting checks, as documented in the installation guide.
Lacks built-in support for common Markdown extensions like GFM; users must install and manage separate plugins, adding complexity.
Features like the --exclude option require Python 3.13+, restricting usability on older or locked-down systems.
Formats only Markdown files, unlike multi-language formatters such as Prettier, making it less versatile for polyglot codebases.
mdformat is an open-source alternative to the following products:
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.